Bob and Alice have in front of them a pile of 2018 rocks, and suggest to play a game.
The rules are as follows:
Assuming each player plays optimally, who will win?
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.
Suppose that Alice is faced with a pile of N stones, where N ≡ 0 , 2 ( m o d 7 ) . The following table shows that, no matter what move Alice makes, Bob can make a responding move which ensures that Alice is faced with a pile of M stones, where M ≡ 0 , 2 ( m o d 7 ) again. N ≡ ? ( m o d 7 ) 0 0 0 2 2 2 A l i c e 1 3 4 1 3 4 B o b 4 4 3 1 4 3 M ≡ ? ( m o d 7 ) 2 0 0 0 2 2 In addition, if Alice is faced with a pile of N stones, where N ≡ 0 , 2 ( m o d 7 ) , then it is not possible for Alice to leave a multiple of 7 stones (so that it is impossible for Alice to take the last stone and win). Since any player can always remove a single stone, a stalemate is not possible. Since 2 0 1 8 ≡ 2 ( m o d 7 ) , we deduce that Bob must always win.
Alternatively, we can show that the Sprague-Grundy function for this game is G , where G ( n ) = ⎩ ⎪ ⎪ ⎨ ⎪ ⎪ ⎧ 0 1 2 3 n ≡ 0 , 2 ( m o d 7 ) n ≡ 1 , 3 ( m o d 7 ) n ≡ 4 , 6 ( m o d 7 ) n ≡ 5 ( m o d 7 ) and so the losing positions for Alice at those for which G ( n ) = 0 , namely those for which n ≡ 0 , 2 ( m o d 7 ) .