According to Wikipedia, it consisting of the sums of distinct powers of 4.
The pattern is look like this: 0, 1, 4, 5, 16, 17, 20, 21, 64, ...
And the part of lookup table is look like this:
| y-x | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
|---|---|---|---|---|---|---|---|---|---|
| 0 | 0 | 1 | 4 | 5 | 16 | 17 | 20 | 21 | 64 |
| 1 | 2 | 3 | 6 | 7 | 18 | 19 | 22 | 23 | .. |
| 2 | 8 | 9 | 12 | 13 | 24 | 25 | 28 | 29 | .. |
| 3 | 10 | 11 | 14 | 15 | 26 | 27 | 30 | 31 | .. |
| 4 | 32 | 33 | 36 | 37 | 48 | 49 | 52 | 53 | .. |
| 5 | 34 | 35 | 38 | 39 | 50 | 51 | 54 | 55 | .. |
| 6 | 40 | 41 | 44 | 45 | 56 | 57 | 60 | 61 | .. |
| 7 | 42 | 43 | 46 | 47 | 58 | 59 | 62 | 63 | .. |
The pattern does exists at the y = 0 of the lookup table,
and you may notice numbers of the table is increment by 1 in zig-zag shape.
The algorithm is quite simple. First, if we make the table above in binary form, it will look like this:
| y-x | 00000 | 00001 | 00010 | 00011 | 00100 | 00101 | 00110 | 00111 | 01000 |
|---|---|---|---|---|---|---|---|---|---|
| 00000 | 00000 | 00001 | 00100 | 00101 | 10000 | 10001 | 10100 | 10101 | ... |
| 00001 | 00010 | 00011 | 00110 | 00111 | 10010 | 10011 | 10110 | 10111 | ... |
| 00010 | 01000 | 01001 | 01100 | 01101 | 11000 | 11001 | 11100 | 11101 | ... |
| 00011 | 01010 | 01011 | 01110 | 01111 | 11010 | 11011 | 11110 | 11111 | ... |
You may notice the relationship between the values and the axis value.
For x-axis, 00001 will be 00001, 00010 will be 00100, and 00100 will be 10000, it maps its bits to odd bits;
and for y-axis, 00001 will be 00010, and 00010 will be 01000, it maps its bits to even bits;
and for the rest of the values, they are just mixing the mapped bits together.
Therefore we have a conclusion here:
If we label the bits for x-axis as 76543210, and y-axis as FEDCBA98,
we should get the result value at specific cell like this: F7E6D5C4B3A29180, which is a simple binary shifting.
So for implementing the lookup function (or inverse lookup function), you will have to do is just make a bunch of bit mask, shift and union.