Here is a position, where the numbers of stones in each pile is written in binary 10111 23 00101 5 01001 9 10110 22 ----------- 01101 13 The result, 01101, is the XOR of the four strings. Find a string among these four that has a one in the same bit as the most significant bit of the result. In this example, there is only one such string, namely 01001. Now, XOR that string with the result, getting 01001 01101 ----------- 00100 which is necessarily a smaller number than that represented by the string 01001. More precisely, the result is 4, so you just reduce the pile with 9 (01001) stones to a pile with 4 (00100) stones, since that is equivalent to adding a pile with 13 (01101) stones to the original position, and adding a pile with the same number of stones as the value of the original position clearly changes the value of the position to 0.