Strategy

A condition of chocolate games are determined by the following two conditions. In the above calculation the symbol made by plus and a circle is nim-sum. Nim-sum is addition without carries for numbers expressed in base 2. Nim-sum is the same as the "exclusive or" in computer science. If you leave chocolate whose cooridinate is nim-sum 0 to your opponent 0 each time, you will win the game.

What is nim-sum？

Nim-sum is the addition without carries for numbers expressed in base 2.

What does it mean to express a number in base 2？

In our daily life we express a number with 0,1,2,...,9, so we use decimal numbers.

When we use binary number, we express a number with 0 and 1.0.

To convert a decimal number to a binary number is not difficult.

For example, the decinal number 22 is 24+22+21 so we put 1 in 24 place, 22place and 21 place. We put 0 in other places. Then we have the binary number 10110.

The calculation of nim-sum

We caluculate nim-sum in two steps. First express numbers in base 2, then we add them without carries.

If the number of "1" is even in each column of 2n place, then the nim-sum is 0.

Winning way

If you leave the condition that nim-sum = 0 to your opponent each time, you finally win the game.