# Get the largest number using the crazy circuit board

There is a crazy circuit board with three kinds of elements which can change the signal value. All intersecting paths are connected (but paths touching by a single point are disconnected).

There is an input line (marked blue) and an output line (marked red).

The circuit can operate with decimal numbers for your convenience. The input value is shown in the left corner. The actions peformed on the signal $s$ by each kind of elements are shown in the right corner.

Choose the path from the input to the output, which gives the largest positive number in the end. Show the path and the resulting value.

Believe it or not, this crazy board is created by a simple cellular automaton with the following rule:

(this has nothing to do with the problem, but this way you can create your own picture if you want).

• Does the board continue beyond the edge of the picture (following the rules of the cellular automata) or is it finite? – 2012rcampion Sep 28 '16 at 21:53
• @2012rcampion, it continues infinitely, but there are disconnected 'levels' of finite height, and the two points are located whithin one such level – Yuriy S Sep 28 '16 at 21:55
• @2012rcampion, in other words, try to go down from any of the two marked points. You will not be able to go lower than a certain height – Yuriy S Sep 28 '16 at 21:57
• OK, I see now. Another question: can the path cross itself, take the same 'wire' twice, or turn around (exit an element the same way it entered)? – 2012rcampion Sep 28 '16 at 22:33
• @2012rcampion, I think no to all of these, except crossing. Crossing is fine – Yuriy S Sep 28 '16 at 22:36

My highest value is

43425

I alternated between red and blue for the path to make the path clearer when the path took the same crossing twice.
To find the solution I started with the great simplification by 2012rcampion. I joined more and more elements into bigger and more complex elements when there was only one path in and out of the group. For example the repeating group of 3 elements can do a 4s+1 or 4s+2 calculation depending on whether you enter by the negator or doubler. This compressed the 16 elements on the bottom half into 256s+616.
This just left the question if I use the start to get to a negative value so I can use the first doubler in the lower half twice or start with a positive value but can only use the first doubler once. The best negative start gives -2 while the best positive start gives 20, so I went with the latter.

(No solution, only some simplifications for other puzzlers.)

We can simplify the circuit by removing all unconnected elements:

Then removing all dead ends, straightening some curves, and removing some useless loops:

And finally, recognizing that:

Two successive negate-and-decrement blocks are a no-op
$-(-x-1)-1=x+1-1=x$

We can remove a few blocks altogether:

• That's very helpful. I thought about doing this myself, but thought it would simplify the problem too much. Still, isn't it curious that a simple CA generates a set of complex closed curcuits... – Yuriy S Sep 29 '16 at 6:26
• Many simple 2-state turmites also generate closed circuits like this. – Anon Sep 30 '16 at 15:27