S06MIRROR MAZE
The task
Two cores of a working program, their pieces swapped about. Swaps stay inside a core.
P must receive a copy of X, which runs from -99 to 99.
The locked core lim lets only 0 to 99 through. Lower values come out as 0.
The board
Key idea
Par is 5 swaps. Core enc needs 1 instruction swap and 1 operand swap; core dec needs 1 instruction swap and 2 operand swaps. 4 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
Whatever lim turns into 0 is a mark.
Hint 2Show
enc sends a value below 1 as itself, then as its opposite. lim turns the first one into 0.
Hint 3Show
dec passes a value above 0 straight on. After a 0 it reads one more and negates it.
Solution
Reveal the Full SolutionThe complete program for MIRROR MAZE. 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.
encSC-1 lite
S: JG P1
OUT P1
IN S
NEG
OUT P0decSC-1 lite
S: IN K
JG P1
OUT P0
NEG
K: IN P05 swaps back
Make these swaps in order. Lines are numbered from 1 in each core.
- In core
enc, swap the operandP1on line 1 withP0on line 5. - In core
enc, swap the instructionJGon line 1 withINon line 3. - In core
dec, swap the operandKon line 1 withP0on line 5. - In core
dec, swap the operandP1on line 2 withKon line 5. - In core
dec, swap the instructionOUTon line 3 withINon line 5.
The finished program
Every tile back in place: the reference solution, which scores exactly par on every benchmark.
encSC-1 lite
S: IN P0
OUT P1
JG S
NEG
OUT P1decSC-1 lite
S: IN P0
JG K
IN P0
NEG
K: OUT P1- CYCLES
- 279
- at par
- ENERGY
- 974
- at par
- NODES
- 2
- at par
- INSTRUCTIONS
- 10
- at par
- SWAPS
- 5
- at par