Skip to content
SmileMath

How to play Nim

Nim is four heaps of pebbles and nothing else. The sides take turns to take pebbles away. You try to be the side that takes the last pebble.

What you need to know

On your turn

Each heap is a row of pebbles. Press a pebble to take it and every pebble to its right. Press the leftmost pebble of a row to take the whole heap. The places that the last move emptied stay marked.

How a match ends

The side that takes the last pebble wins. Every turn removes at least one pebble, so a match always ends and the rules give no draw.

Each side has a clock for the whole match, and a side that runs out of time loses. You can resign at any point, and the two sides can agree to a draw.

Try this

Start with the end. If one heap is left, take all of it and win. If two heaps are left, make them equal. Suppose the heaps hold 5 and 3. Take 2 from the larger one to leave 3 and 3. From then on, copy your opponent: whatever they take from one heap, take the same from the other. You will take the last pebble.

The same idea covers more heaps. Split each heap into parts of 8, 4, 2 and 1. A heap of 3 is 2 + 1, a heap of 5 is 4 + 1, and a heap of 6 is 4 + 2. In the heaps 3, 5 and 6, each part appears twice: two 4s, two 2s and two 1s. A position where every part appears an even number of times is the one to hand to your opponent. Any move they make breaks it, and you can always repair it.

Say three heaps are left and they hold 3, 5 and 7. The 7 is 4 + 2 + 1, so there are three 1s. Take one pebble from the 7 to leave 3, 5 and 6. If the position is already even on your turn, take one pebble and wait for a mistake.

Advertisements