3 ms·
Here the example for 3 bits. 0 -> 0 +1 -> -2 -> -1 -> +2 -> +1 +3 -> -4 -> -3 -> -4 The first cycle takes care of 0, the second one of -2, -1, +1 and
by danbruc 13y ago
Here the example for 3 bits.
0 -> 0
+1 -> -2 -> -1 -> +2 -> +1
+3 -> -4 -> -3 -> -4
The first cycle takes care of 0, the second one of -2, -1, +1 and +2. The interesting thing is the third thing - it consists of the cycle -4 -> -3 -> -4 and the attached chain +3 -> -4 entering the cycle via -4. This one correctly maps +3 to -3 and -4 to -4 (-(2^(n - 1) is its on inverse) and only fails for -3 which is incorrectly mapped to itself, too. There you go, 7 out of 8 correct.
(This is the essence of my way longer answer on Stack Overflow [1] although it is not necessarily any clearer because it evolved a lot.)
[1] http://stackoverflow.com/a/731857 http://stackoverflow.com/a/731857