If the user picks illegal number of sticks the program will


The game of "23" is a two-player game that begins with a pile of 23 toothpicks. Players take turns, withdrawing either 1,2, or 3 toothpicks at a time. The player to withdraw the last toothpick loses the game. Write a human vs. computer program that plays "23". The human should always move first. When it is the computer's turn, it should play according the following rules:

a. If there are more than 4 toothpicks left, the computer should withdraw 4 - X toothpicks, where X is the number of toothpicks the human withdrew on the previous turn.

b. If there are 2 to 4 toothpicks left, the computer should withdraw enough toothpicks to lave 1.

c. If there is 1 toothpick left, the computer has to take it and loses.

When the human player enters the number of toothpicks to withdraw, the program should perform input validation. Make sure the entered number is between 1 and 3 and that the player is not trying to withdraw more toothpicks than exist in the pile.

1. If the user picks illegal number of sticks, the program will prompt the user to repick.

2. At the end of each game, the program will prompt user to choose if the user wants another game.

Solution Preview :

Prepared by a verified Expert
Basic Computer Science: If the user picks illegal number of sticks the program will
Reference No:- TGS02340154

Now Priced at $20 (50% Discount)

Recommended (92%)

Rated (4.4/5)