Learn / Library / Brainteasers
Which starts to avoid
In a game for players, a pile starts with beads. Players alternate, and each move removes exactly or exactly beads; a move that needs more beads than remain is not allowed. A player who cannot move loses. Both players play optimally. For how many starting values of from to does the second player win?
Checking an answer needs JavaScript. The hint and the solution open without it.
Hint
Classify small piles as won or lost for the player to move until the pattern repeats.
Solution
- Piles of and are lost for the mover, since no move is possible.
- Piles of and are won by moving to or , pile is lost because it only reaches , and piles and are won by reaching or .
- From then on the pattern repeats with period , so the lost piles are those with remainder , or on division by .
- From to there are values with remainder , with remainder and with remainder .
- So the second player wins for starting values, and the answer is .
Answer: