Two players play a game according to the following rules:
They place three heaps of coins on a table. The first heap has coins, the second heap has coins, and the third heap has coins.
The second player adds another pile of coins on the table, having at most coins.
The players take turns alternately, starting with the first player. At each move, the player has to remove a positive number of coins from one heap. The player who removes the last coin wins.
It turns out that regardless of the strategy of the first player, the second player always wins with optimal play. How many coins should the second player add in the fourth pile?
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
This is just the game of Nim . If the last pile has x coins, the nim-sum will be 1 0 ⊕ 7 ⊕ 9 ⊕ x = 4 ⊕ x . Since the second player would want this to be zero such that he can guarantee a win, the desired x is 4 .