# Nim - A Devilishly Difficult Game

Players: 2
Ages: 7 and up
Cost: Free!
Math Ideas: Subtraction, deductive reasoning, mathematical proof
Want to figure out a strategy to always win?
Do you want to go first or second this time?
If you make that move, what do you think I will do?

Years ago, a teacher friend sent me an online version of the game Nim. "Try it out!" they said innocently enough, "See if you can figure out the strategy!"

The game seemed simple enough, basically just a set of three rows of objects. So I gave it a shot, and I lost. And then I lost again, and again. I finally walked away from my computer, a broken man.

In the years since then, I've moved cities and schools, had three kids, and STILL CANNOT BEAT THIS GAME.

In preparation for this newsletter, I finally gave in and looked up the solution. And having seen a lovely explanation from one of my favorite mathematicians, James Tanton, I think I can provide a way to turn this maddening little game into a meaningful mathematical exploration for you and your child.

## How to Play

Nim is an ancient game with many variations, but each version is based on the same idea: rows of stones.

The original version I played had three rows of stones, as pictured. But you can have as many rows of stones as you want, and each row can contain as many stones as you like.

You and your opponent take turns choosing a single row of stones and then removing as many stones from that row as you want. You can remove a single stone, a few stones, or even the entire row. The person to take the last stone wins.

You can play an online version of the game with four rows here. The version I played has been lost to the sands of time (Good riddance).

## Playing Nim with your Child

Have you played the version above a couple of times? Have you lost every time, just like me? Great, you're ready to explore this game with your child!

I don't usually get this prescriptive with my advice, but I think that Nim provides a great opportunity to show your child one of the greatest problem-solving skills of a mathematician: solving a simpler problem.

Introduce the game to your child, then play a couple of versions of Nim that start with two rows. Then ask them "Do you want to figure out a strategy to always win?" Kids love nothing so much as winning, so hopefully they'll be on board!

Start with a very simple version of Nim: a one-row version of the game. Lay out a row of stones and ask your child "Do you want to go first or second?" Hopefully, they choose to go first and snatch up all the stones! If not, snatch all the stones yourself on your turn, then set up the game again and ask if they want to go first or second.

This version of the game isn't very fun, but it does teach you and your child an important principle of the game: if there is only one row left on your turn, you win!

Now you're ready to play the two-row version of the game. Again, though, you want to start with a simplified version: one stone in each row. Again, ask your child "Do you want to go first or second?"

This time, going first is a guaranteed loser! No matter which stone you choose, your opponent can take the other stone to win. So now you and your child have another piece of strategy about the game: if you can get the stones down to a single stone in each row on your opponent's turn, you win!

One last mini-game before the final reveal: set up a game with two stones in each row and ask your child "Do you want to go first or second?"

Now you can start to discuss all the possible ways the game can go: If you choose to go first, you can either take a single stone from one row, or you can take both stones from one row. But taking both stones is a bad move, since your opponent will just snatch up both stones from the other row and win!

So you have to take a single stone from one row. But wait! Your opponent can take a single stone from the other row, leaving you with one stone in each row, a situation we know is hopeless! So two rows of two stones are equally as hopeless as two rows of one stone. In fact, two equal rows of stones are a guaranteed loser, no matter how many stones are in each row.

And now the strategy becomes clear: On your turn, take stones from the bigger row until both rows are equal. That way, you force your opponent to make the rows unequal on their next turn, and you can make the rows evenly matched again on your turn. Eventually you will winnow down the rows until each row has exactly one stone, and your opponent is doomed!

The beauty of this game is that this strategy works no matter how many stones are in each row. Once you know the goal of making the two rows equal, you can play any variation on the two-row version of Nim. And what if the two rows start out equal? Simple, just ask your opponent to go first! She'll break up the evenness of the rows, and you are back on track to victory.

I think for most kids in elementary school, the two-row version of Nim is perfect. They get the feeling of accomplishment that they know how to beat the game, and they're sure to teach their friends how to play, simply to show off their prowess.

More importantly, though, they have gone through the experience of solving a game by solving simpler versions of a complicated problem. This is a tool that I teach my students to use in middle school, and it's a tool I use as an adult to solve mathematical problems that I've never encountered before. By modeling this process, you are giving your child an opportunity to experience the joy of mathematical discovery.

But wait - we haven't solved the three- and four-row versions of Nim, the ones that drove me crazy for years! That's true. But we have learned something valuable about the structure of Nim, which is that keeping the rows even somehow is a good strategy. In order to see how you can keep three or four rows even, you'll have to watch that lovely video from James Tanton that I mentioned earlier.