Here’s my solution (it’s the one from the book):
And here’s the link:
Description: To understand this solution, you’ve got to realize that doubling a binary number is the same as shifting all the bits up one place. For instance:
(reading from the top bit to the bottom bit, left to right)
1100 = 3
0110 = 6
0011 = 12
So each ball that drops sets the value of the gear bits below it to whatever it was.