Learn / Library / Brainteasers
Tokens in a jar
A jar holds tokens. players take turns removing , , or tokens from the jar. The player who removes the last token wins. You move first and both players play optimally. How many tokens must you remove on your first move to guarantee a win?
Checking an answer needs JavaScript. The hint and the solution open without it.
Hint
Find the jar sizes that are lost for the player who has to move.
Solution
- With tokens left, whatever the mover takes, from to , the other player takes the rest and wins.
- By the same reasoning every multiple of is a lost position for the mover, since the reply to a move of keeps the count a multiple of .
- The largest multiple of below is , and .
- So you remove tokens on your first move.
Answer: