Two take-away games
Statement
- A pile contains stones. Two players alternately remove between and stones. The player who takes the last stone wins. For which does the first player have a winning strategy?
- There are two piles with the same number of stones. Two players alternately remove any positive number of stones from one pile of their choice. The player who takes the last stone wins. Who wins?
Hint
For part 1, find the positions that are lost for the player to move, starting from small . For part 2, think of a pairing strategy.
Show solutionHide solution
Solution
1. Winning positions. Positions are winning for the player to move. The position is losing. We claim the first player loses if and only if .
- *If :* the second player answers each move "remove " by "remove ", which is legal. After each of his moves the number of stones is a multiple of . The first player can never take the last stone.
- *If :* the first player removes stones, leaving a multiple of and then plays the second player's strategy above.
Answer 1. The first player wins iff is not a multiple of .
2. Pairing. The second player wins. After each move of the first player, he removes the same number of stones from the other pile. Then the piles are equal after each of his moves. The first player can never take the last stone; the second player finishes by taking the last stones of the second pile.
Remark. These are the simplest cases of impartial game theory (Sprague–Grundy); the general sum-of-piles result is Bouton's solution of Nim.
Lesson. Compute the losing positions from the end of the game, then find a complement strategy.