The Program.
You have been asked to solve a problem for an old gameplayer. She has purchased a new game. It is a sort of Solitaire. This suits the old gameplayer as she has no friends so a game played alone is ideal.
The game is played on a triangular grid. That is there are 7 rows of holes. The bottom row consists of just one hole and the top row of seven holes. Every hole has a red peg in it except the bottom hole.
A move in this game consists of a red peg jumping over one of its neighbours into an empty hole beyond, and then removing the peg jumped over (like taking in draughts). In this game a peg has up to six neighbours.
The diagram shows a stylised board with red squares indicating pegs. The black square indicates a missing peg. The six pegs which could jump into the vacant space (according to the rules) are marked with yellow circles.
The idea is to make move after move until there is just one peg left. Ideally it should be in one of the three corners and best yet it should be in the bottom corner.
However, as a good gameplayer she wants to generalise the game she's bought. She wants to know for which sizes of boards the game can be completed leaving just one peg standing. She also wants to know when the last remaining peg can be left in a corner, and when it can be left in the bottom corner.
You are to write the program which gives her these answers.

Your program should prompt for the size (number of rows, up to eight) of the board.
You should output one of the sentences:

  • This game cannot be completed.
  • This game can be completed but not with the last remaining peg in a corner.
  • This game can be completed leaving a peg in a corner, but not in the top corner
  • This game can be completed leaving the last peg in the bottom corner.

Have you done any work yourself? If so please post it with specific questions for help. Otherwise we do not allow members to ask other members to do their homework for them. Please show some effort before asking for help.

Jus nid help wid sm few codings wich myt b of use to this game, aint askin ny1 to do it 4 me since it aint a homework bt jus a topic of interest i picked up frm smwea. Any help wil be appreciated. Thnx

Jus nid help wid sm few codings wich myt b of use to this game, aint askin ny1 to do it 4 me since it aint a homework bt jus a topic of interest i picked up frm smwea. Any help wil be appreciated. Thnx

Having a little trouble spelling words?

Obviously he hasn't done any code yet, otherwise he would already know what language he needs help in.
Pick a language to use, start working on the problem, then ask the forum if something 'specific' is troubling you.

Its Java. If i remember correctly, a tutorial for an app very similar to this is available (i think it may be from the netbeans site actually....)

Jus nid help wid sm few codings wich myt b of use to this game, aint askin ny1 to do it 4 me since it aint a homework bt jus a topic of interest i picked up frm smwea. Any help wil be appreciated. Thnx

come again?

This question has already been answered. Start a new discussion instead.