3.3

# How to win at Nim

Nim is a really fascinating game. Now for some of the math behind it…

## The solution to the 1,2,3 one pile Nim game

Here is the answer to the 1,2,3 ten stone, one pile Nim game.

What we have to realise is that the player who is left with a pile of 3,2 or 1 stones is going to be the winner, but the player who is left with 4 stones in the pile is definitely a loser.

So, the winning strategy of the first player is to try and leave the second player with a four stone pile.
If we had 5,6 or 7 stones in the original pile, the first player could easily do this, by taking 1,2 or 3 stones to leave the second player with 4 stones and a losing position.
Unfortunately, the initial pile is bigger and has ten stones.
The question now becomes how can the first player force the second player to leave him with 5,6 or 7 stones - positions from which he (the first player) can win.

Luckily, the first player can do this by taking two stones from the initial ten stone pile, leaving 8 stones in the pile for the second player. However many stones the second player now takes, 1,2 or 3, he leaves 5, 6 or 7 stones in the pile from which the first player can take the necessary number of stones to leave the second player with the losing four stone position.

In fact, you may have realised by now, that any multiple of 4 is a losing position for the second player. This means that if you play Nim against someone using the 1,2 or 3 rule, make sure you don’t have a multiple of four number of stones in your initial pile…

A friend of mine, the stand up mathematician, Matt Parker, has a beautiful explanation of the 1,2,3 Nim game. You can see it in the following YouTube video.