A game of
nim is played with one pile of 30 tokens. The two player takes turns taking tokens off the pile. Whoever takes the last token wins.
To make the game a little more interesting, the rules have been changes slightly:
A player may take 1, 3, 4, or 5 tokens but not 2.
What is the best starting move and what is the general strategy?
If the number of tokens remaining is 0 or 2 mod 8, then the player is in a losing position.
If the number of tokens remaining is 1 mod 8, then the only winning move is to take 1 token.
If the number of tokens remaining is 3 mod 8, then the possible winning moves are to take 1 or 3 tokens.
If the number of tokens remaining is 4 or 6 mod 8, then the only winning move is to take 4 token.
If the number of tokens remaining is 5 mod 8, then the possible winning moves are to take 3 or 5 tokens.
If the number of tokens remaining is 7 mod 8, then the only winning move is to take 5 tokens.
In the case of 30 tokens in the problem: Since 30 mod 8 = 6, The first player can win by taking 4 tokens.