Problem

Game Write a program that allows the user to challenge the computer to a game of Pic...

Game Write a program that allows the user to challenge the computer to a game of Pick-Up Sticks. Here is how the game is played. The user chooses the number of matchsticks (from 5 to 40) to place in a pile. Then, the computer chooses who will go first. At each turn, the contestant can remove one, two, or three matchsticks from the pile. The contestant who removes the last matchstick loses. See Fig. 5.41.

The computer should make the user always select from a pile where the number of matchsticks has a remainder of 1 when divided by 4. For instance, if the user initially chooses a number of matchsticks that has a remainder of 1 when divided by 4, then the computer should have the user go first. Otherwise, the computer should go first and remove the proper number of matchsticks. [Note: The remainder when n is divided by 4 is (n Mod 4).] After writing the program, play a few games with the computer and observe that the computer always wins.

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 5