The Secret of Nim

The secret starts with an operation on binary numbers. If you have numbers written in binary, like 101 and 110, the operation consists of adding in the columns and throwing away the remainder. Even easier to remember is the following way of doing the operation. If there is an even number of 1's in a column, write 0 at the bottom; otherwise write 1. Here are some examples:
101         1     100
110        10     111 
---        11      11
011       100     100 
          101     --- 
          ---     100
          001
If you know something about electronics, you may recognize this as an XOR operation.

If you are playing Nim, write down the number of matches in each row in binary and do this operation. If you have a nonzero answer, you can always remove matches to get a zero result. If you get a zero answer, anything you do will leave a nonzero result. The winner, of course, leaves no matches at all, which is a zero result. So always play to leave a zero result for the operation.

If your position looks like this, you can win.

The operation is the middle example above. If you remove one match from either row 1, row 3 or row 5, you will keep the advantage.


This page is maintained by: Robert F. Rossa who can be reached at rossa@csm.astate.edu
Last revised on: 03/27/96