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

Next steps