Problem #WSP-000009

Problems Discrete Mathematics Algorithm Theory Game theory

Problem

Let us define XOR (or addition mod 2). XOR is defined for 0 and 1 only. Here is a table recording the values of XOR:

XOR 0 1
0 0 1
1 1 0

Now we define the important concept of nim-sum. Given two natural numbers x and y, we first convert them into binary representations and then compute XOR on individual digits. The resulting number, denoted xy, is the nim-sum of x and y. Here is an example.

1 0 1 1 0
XOR 0 0 1 0 1
1 0 0 1 1

This is simply saying 225=19. Note that 22=(10110)2 and 5=(00101)2.

Verify (xy)z=x(yz), so we can speak of xyz with no ambiguity.