Here’s my solution (it’s the one from the book):

And here’s the link:

http://www.lodev.org/jstumble/?board=0e0reellleerxx1eelxxrerllrlelgaegaeraralelrrlererleel

**Description:** To understand this one, remember the binary value of each number:

1 = 10

2 = 01

3 = 11

So the way this solution works is by testing each of the 3 ramps on top and then flipping the corresponding gear bits for it’s binary value.

It checks each ramp bit with a 4 ball cycle. The first ball tests the ‘3’ ramp bit. If it’s right, it flips the 1’s place of register A. The second ball tests the ‘2’ ramp bit. If it’s right, it flips the 2’s place of register A. The third ball tests the ‘3’ ramp bit again. This time, if it’s right, it flips the 2’s place of register A. The fourth ball tests the ‘1’ ramp bit. If it’s right, it flips the 1’s place of register A.

The gear bits are set up as latches so they can never be flipped back to 0.