Sanamaq · Blog

The game of Nim: rules and a winning strategy

For parents · 3 min read

Nim is an ancient two-player game that needs nothing but matchsticks or pebbles. Its charm is that it has a winning strategy — and a child can discover it on their own.

Rules (simple version)

The secret to winning

After your move, try to leave your opponent a number of matchsticks that’s a multiple of 4: 12, 8, 4. However many they take (1–3), you make it up to 4 and again leave a multiple of 4. At the end your opponent will leave you 1–3 matchsticks — and the last one is yours.

So with 15 matchsticks, the first player takes 3 and leaves 12 — from then on they win no matter how the opponent plays.

Don’t reveal the strategy right away. Play 5–10 rounds and ask: “Why do you think I always win?” That’s real mathematical research.

What it teaches

Thinking several moves ahead, looking for patterns and testing a hypothesis. It’s the same logic as in olympiad problems. More logic puzzles in Sanamaq.