Interview Prep

21 Sticks Game Answer: Take 1 to Win [Solved]

21 sticks game answer featured image: 21 matchsticks in a row, first move takes 1 stick

The 21 sticks game answer is to take 1 stick first, then always make your take and your opponent’s take add up to 4. Do that, and you take the last stick and win every time, no matter what your opponent does.

Here is the question, as it appears in interview-prep collections and game-theory courses. You and an opponent face a pile of 21 sticks, and you take turns removing 1, 2 or 3 sticks. The player who takes the very last stick wins. You move first. How do you guarantee a win?

The Question, Stated Plainly

Two players, one pile, 21 sticks. Each turn, the player whose turn it is removes 1, 2 or 3 sticks, and the pile only shrinks, so the game must end. The player who removes the last stick wins. You move first.

Three details matter. First, both players see the pile, so there is no hidden information and no luck. Second, you cannot pass a turn, and you cannot take zero sticks or more than three. Third, only the last stick decides the winner, not who takes the most sticks overall.

The 21 Sticks Game Answer in One Line

Take 1 stick first, leaving 20. After that, whatever your opponent takes, take enough to make the two takes add up to 4. If your opponent takes 1, you take 3. If your opponent takes 2, you take 2. If your opponent takes 3, you take 1.

Each full round removes exactly 4 sticks, so the pile falls 20, 16, 12, 8, 4, 0, and you take the last stick. Your opponent can change the numbers inside a round, but the total stays at 4, so the result never changes.

The 21 Sticks Game Answer, Round by Round

Here is one full game, with the opponent making a different choice in every round. Watch the pile after each pair of moves.

Round You take Opponent takes Sticks left
First move 1 – 20
1 2 2 16
2 1 3 12
3 3 1 8
4 2 2 4
5 3 1 0

Check it. You take 1 first, leaving 20. Each round removes 4: round 1, opponent takes 2, you take 2, leaving 16; round 2, opponent takes 3, you take 1, leaving 12; round 3, opponent takes 1, you take 3, leaving 8; round 4, opponent takes 2, you take 2, leaving 4; round 5, opponent takes 1, you take 3, leaving 0. You win.

Try a different opponent. If your opponent takes 3 in every round, you take 1, and the pile still falls 20, 16, 12, 8, 4, 0. If your opponent takes 1, you take 3, with the same result. The choices change the shape of each round, but not the total.

Why the 21 Sticks Game Answer Works

The proof works backward from the end of the game, starting with the pile sizes that spell trouble for the player to move.

Start with 0 sticks. The game is over, and the player who just moved has won, so the player to move has lost. Now look at 4 sticks: any move leaves 3, 2 or 1 sticks, and the next player takes them all and wins. So 4 sticks is a losing position.

Next, look at 8 sticks. Any move leaves 7, 6 or 5, and from each the next player can move back to 4: take 3 from 7, 2 from 6, or 1 from 5. So 8 sticks is also a losing position. The same argument repeats for 12, 16 and 20 sticks.

Pile size Safe for the player to move? Why
4 No Any move leaves 1 to 3, and the opponent takes them all
8 No Any move lets the opponent reply back down to 4
12 No Any move lets the opponent reply back down to 8
16 No Any move lets the opponent reply back down to 12
20 No Any move lets the opponent reply back down to 16
21 Yes Take 1 and leave 20, a losing position

That is why the first move is 1. The number 21 is not a multiple of 4, since 21 equals 4 times 5 plus 1. Taking 1 stick leaves 20, a multiple of 4, and the reply rule does the rest. The general rule is simple: when the pile is not a multiple of 4, take the remainder and leave a multiple of 4. With 22 sticks, take 2; with 19, take 3.

The Trap Most Candidates Fall Into

The most common wrong answer is to take 3 sticks first, because taking the most feels like winning. It is the worst opening. Taking 3 leaves 18, and your opponent takes 2 to leave 16, a multiple of 4. From there, your opponent runs the same reply rule against you. Taking 2 first is no better: it leaves 19, and your opponent takes 3 to leave 16.

A second trap is to treat the game as a race. The total you take does not matter. In the worked game above, you took 12 sticks and your opponent took 9, but the counts could easily flip. Only the last stick decides the winner.

What the Interviewer Is Testing in the 21 Sticks Game

This question tests backward induction, the habit of reasoning from the end of a problem back to the start. Strong candidates find the losing positions first, then work out the move that hands one to the opponent. Weak candidates start grabbing sticks and hope the ending works out. The 21 sticks game answer is a test of structure, not of speed.

It also tests whether you can spot an invariant, a quantity that stays fixed while everything else changes. Here the invariant is the total removed in each round: always 4. Once you see it, the game stops looking random and becomes mechanical. Interviewers in trading, quant and tech roles prize that shift, because real markets and real code reward the same move.

Finally, it tests composure. The game gives your opponent free choices, and a nervous candidate tries to control those choices. A calm candidate accepts them, builds a reply for every case, and names the rule out loud: “Whatever you take, I take 4 minus your number.”

Try the Twist: When the Last Stick Loses

Some interviewers flip the ending: the player who takes the last stick loses. This version is called misere play, and the losing positions shift by one, to 1, 5, 9, 13, 17 and 21. From a pile of 21, the player to move loses with best play, so the right choice is to go second.

As the second player, your target is to leave 17, then 13, 9, 5, then 1. Whatever your opponent takes, take 4 minus that number, and the pile falls by 4 each round: 21, 17, 13, 9, 5, 1. Your opponent then faces a single stick, must take it, and loses. The same reply rule wins; only the target pile changes.

Try Another Puzzle Next

If you liked the 21 sticks game answer, try the Goldman Sachs 5 pirates puzzle, where five pirates split 100 coins and the answer also comes from reasoning backward from the last pirate. For a racing version of the same skill, try the 25 horses puzzle, which finds the fastest three horses in only seven races. And for a probability classic that rewards the same calm, step-by-step thinking, try the 100 prisoners boxes puzzle, where the answer is a surprising 31 percent.

Can the second player ever win the 21 sticks game?

Yes, but only if the first player makes a mistake. With best play from 21 sticks, the first player wins every time. If the first player takes 2 or 3 sticks instead of 1, the second player can reply to a multiple of 4 and win instead. Going first wins only when the pile is not a multiple of 4.

What if the pile has 20 sticks instead of 21?

Then the player to move loses with best play, because 20 is a multiple of 4. Any move leaves 19, 18 or 17, and the opponent replies back down to 16. If you are offered the choice, pick the second move with 20 sticks, and let your opponent face the losing position.

What if each player can take 1 to 4 sticks?

Then the losing positions become the multiples of 5. From 21 sticks, take 1 to leave 20, then complete each round to 5. The pile falls 20, 15, 10, 5, 0, and you take the last stick.

Sources: the game appears in interview-prep collections, including the 21 matchsticks problem on GeeksforGeeks, and in game-theory teaching such as the Nim and 21 game guide on Play Board Games. The wording, the worked game and every explanation above are original.

Enjoying this? Add StudyFromNotes as a preferred source on Google to see our latest notes and updates more often:

Leave a Reply

Your email address will not be published. Required fields are marked *