The 21-match game (the last match loses)
product-puzzle case · difficulty 3/5 · 15 minutes · other
Prompt
21 matches lie on a table. You and an opponent take turns removing 1, 2 or 3 matches. The player who takes the last match loses. You go first. Is there a winning strategy for you?
Context
A classic interview puzzle. Core idea: Leave multiples of 4 plus 1. Take 4 matches first. Talk through your reasoning; the interviewer cares as much about structure as about the answer.
Clarifying questions
- Can you force a multiple?
- Yes. Each turn you must take exactly 1, 2 or 3 matches, never more, and whoever takes the last match loses. You cannot force a multiple of anything beyond that, because of the limit of 3.
Recommendation
**Answer:** No: against perfect play, the first player cannot force a win from 21. The second player wins by always answering my take of k with 4 - k, leaving 17, 13, 9, 5 and then 1 matches, so I end up taking the last match. If I could choose, I would go second. **Why:** The second player can always make each pair of turns remove exactly 4 matches, which keeps the count at 4k + 1 after his turns, and the first player is forced to take the last one.
Risks
- Saying "take 4 matches first", which is not allowed since the limit is 3 per turn
- Using the normal-play rule where the last match wins, which gives the opposite pattern
Next steps
- Find the right first move with 22 matches (take 1, leaving 21)
- Check what happens if you can take 1 to 4 matches: the losing positions become 1, 6, 11, 16, 21, so 21 is still losing