My “solution” is not based on the setup in the Puzzle Book, but it produces the same output using a simpler design. See attached pdf file for a discussion.
challenge 39 my way.pdf (52.9 KB)
Here is the link that will show you the program in action:
https://www.lodev.org/jstumble/?board=rlerlf0fer0fex0frr0frr1frlifxfelrel