2 ms·
This also applies to more complicated things than bouncing around a rectangle. For instance, solving a Towers of Hanoi puzzle, where the i'th step in a solution
by tromp 4y ago
This also applies to more complicated things than bouncing around a rectangle.
For instance, solving a Towers of Hanoi puzzle, where the i'th step in a solution is to move a disc from peg (i&i-1)%3 to peg ((i|i-1)+1)%3). (Note that for even #discs, peg 1 is the destination). Example for 3 discs:
i i-1 i&i-1 from i|i-1 to
1 0 0 0 1 2
2 1 0 0 3 1
3 2 2 2 3 1
4 3 0 0 7 2
5 4 4 1 5 0
6 5 4 1 7 2
7 6 6 0 7 2