I got the same as book solution just a few extra ramps.
But maybe makes it easier to see what is going on.
If 1st bit is ON it turns the next bit ON, thereby doubling the register and then ejects the ball (yellow trace).
If 1st bit is OFF it turns the next bit ON then OFF straight away by action of the connecting gear (blue trace)
Results: