Headass, cracks E by thejonymyster
This is Turing complete because it can simulate a Minsky machine with two registers.
r1 and r2 will be used as the two registers of the Minsky machine. r3 will store the state.
The program has the following structure: initialisation { state handlers ;}:;
Each non-halting state, with one exception, has a positive state number and a state handler of the form >>+state number) core : (the superscript denotes repetition). >> sets r0 to 0, then the +s increase it to the state number, and the ) checks if that equals the current state. If it does, the core executes, and then the : jumps to after the first ;. Otherwise, the ) jumps to after the :, continuing execution into the next state handler.
The exception is the last non-halting state, which omits the :, so that a mismatch instead jumps to the : outside the loop, ending the execution.
The core of a state handler has these four possibilities:
- Increment r1 and change to state s:
D+^>>+s( - Increment r2 and change to state s:
>>]+[+s( - If r1 is zero, change to state s; otherwise decrement it and change to state t:
>>+s(D^+s>)D-^>>+t( - If r2 is zero, change to state s; otherwise decrement it and change to state t:
>>+s(<]>)>>]-[+t(
For both of the decrement cases, the state handler for state s must come after the decrementing one; otherwise, the program will incorrectly stop. This can be ensured by rearranging the state handlers or, if necessary, inserting extra states in between.
Finally, the initialisation is D>>+a^>>+b[+s( to set r1 to a, r2 to b, and the state (r3) to s.