Introduction to Programming Using Visual Basic

Visual Basic Programming Challenge 5-pp5: Pick Up Sticks Game

Write a program that allows the user to challenge the computer to a game of Pick Up Sticks.

Game Rules:

The user chooses the number of matchsticks from 5-50 to place in pile. Then, the computer chooses who will go first.

At each turn, the contestant can remove 1, 2, or 3 matchsticks from the pile. The contestant who removes the last matchstick loses.

The computer should make the user always select from the 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 reminder 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 and observe that the computer always wins.

## Comments