Winning way of NIM
The case of two piles
Winning way is to make the number of stones the same.
The case of three cases
Winning way is to make the nim-sum of the numbers of stones of piles equal to 0.
How to calculate nim-sum.
To calculate the nim-sum of two numbers x and y is to express them in base 2 and add them without carryies.
For each n, we count the number of 1 that are contained in the column for 2
n. If the number of 1 is even for each n, then the nim-sum of these three number is 0.
The nim-sum is very important concept for combinatorial games including chocolate games.
NIM is mathematically the same as Rectangular Chocolate Game.