This seems to work for all cases:
Hmm. If I start with this board and then set bit A and gear bit B to both point to the right, it appears to intercept a blue ball, when I think it should intercept a red ball. But I may be doing something wrong.
No, it doesn’t show the same output as written in the book.