S05SWITCHBACK
The task
Every piece of a working gate is here, out of place. Swap them back.
When Y is above 0, P must receive the next X. Otherwise Q must receive it.
The board
Key idea
Par is 4 swaps. Core g needs 2 instruction swaps and 2 operand swaps. 3 of them trade two tiles that hold each other's places; look for those first, since one swap mends both.
Hints
Each hint goes a step further than the one before. Open them one at a time.
Hint 1Show
Read Y, jump on it, and only then read X. The jump remembers what Y said.
Hint 2Show
Every X goes somewhere, so both branches read it.
Hint 3Show
Instructions swap with instructions and operands with operands, inside one core.
Solution
Reveal the Full SolutionThe complete program for SWITCHBACK. Open it only when you want the answer.
The board as dealt
This is the arrangement the game deals. Framed tiles are the ones out of place.
gSC-1 lite
S: IN P1
OUT P2
IN P0
IN P3
JMP K
K: OUT P0
JG S4 swaps back
Make these swaps in order. Lines are numbered from 1 in each core.
- In core
g, swap the operandP2on line 2 withKon line 5. - In core
g, swap the operandP2on line 5 withSon line 7. - In core
g, swap the instructionOUTon line 2 withJGon line 7. - In core
g, swap the instructionINon line 4 withOUTon line 6.
The finished program
Every tile back in place: the reference solution, which scores exactly par on every benchmark.
gSC-1 lite
S: IN P1
JG K
IN P0
OUT P3
JMP S
K: IN P0
OUT P2- CYCLES
- 219
- at par
- ENERGY
- 531
- at par
- NODES
- 1
- at par
- INSTRUCTIONS
- 7
- at par
- SWAPS
- 4
- at par