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

And here’s the link:

http://www.lodev.org/jstumble/?board=00rrrre0l0eerrrree0l0eerrrree0l0lerrrleerxlfixf

**Description:** The solution adds one to each register in turn, starting with the right register. If the right register overflows first (i.e., it goes over 15), then a red ball goes in the basket. If the left register overflows first, a blue ball goes into the basket.

For example:

Starting register values:

A: 12

B: 13

After 1 red and 1 blue ball:

A: 13

B: 14

After 2 red and 2 blue balls:

A: 14

B: 15

After 3 red and 3 blue balls:

A: 15

B: overflow (red ball in basket, indicating that A was not greater than B)