You are in a room facing your opponent with a table separating both of you. There are 11 pebbles on the table and you and your opponent will take it in turns to remove pebbles from the table. On each turn, the player is allowed to take 1, 2 or 3 pebbles. The person who takes the last pebble loses. It is your turn to take pebbles first. How many pebbles do you take?
Scroll down for a clue and further down for the answer.
*
*
*
*
*
*
*
Clue: You are guaranteed to win if a certain number of pebbles remain after your turn. Eventually, you want 1 pebble to remain after your turn. Can you work out what the other numbers of pebbles you wish to remain on previous turns?
Scroll down for the answer.
*
*
*
*
*
*
*
Answer: You take 2 pebbles away so there are 9 remaining on the table after your first turn. If your opponent then:
takes 1, you take 3
takes 2, you take 2
takes 3, you take 1.
5 pebbles will then be remaining on the table with your opponent to move.
If your opponent then:
takes 1, you take 3
takes 2, you take 2
takes 3, you take 1.
After your turn, there will be 1 pebble remaining on the table and it will be your opponents turn and they have to take this pebble and lose.
This puzzle is based on the ‘game of nim’. There are variants to the above game in which:
A. The person who takes the last item wins
B. There are more or less items than the 11 mentioned in the puzzle.
C. Players are permitted to take a different range of items than the 1-3 listed in the puzzle.
D. There are many variants online involving rows of items, with only items from one row allowed to be taken per turn.
E. There are many wildly more creative versions of the game including: the 100 game, circular nim, Greedy nim and Grundy’s game.
In the puzzle variant, there are certain ‘safe’ numbers that you want to achieve after your turn. These are:
1, 5, 9, 13, 17, 21 etc depending on what number you start at. The trick is to reach the next safe level after each of your turns.
The game of nim doesn’t need to be played with items and you can just as easily annoy your friends by playing this game verbally and beating them.
In the variant during which players can take 1 or 2 items, the safe numbers are:
1, 4, 7, 10, 13, 16, 19.
The formula for determining the safe numbers is:
M= Maximum number of items you are allowed to take in the variant.
N=1, 2, 3 etc. You put these numbers in the equation to determine the safe number for different levels.
1+ (N x (M+1))
Play the game of nim online here: https://education.jlab.org/nim/s_gamepage.html In this variant, the person who takes the last pebble wins. Can you work out the safe numbers?