Syscall 2: Firmware, home

ShuffleChapter 8: Scarcity

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

The board of MIRROR MAZE3 cores: enc, lim, and dec. Locked: lim. Inputs X; outputs P.encSC-1 8 LINESlimLOCKEDIN P0JG OMOV A, 0O: OUT P1decSC-1 8 LINESP0P1P0P1P0P1XP
The board as the puzzle screen lays it out. Cyan pins read, lemon pins write, violet pins go both ways. On a narrow screen, scroll the board sideways to see all of it.

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 P0

decSC-1 lite

S: IN K
JG P1
OUT P0
NEG
K: IN P0

5 swaps back

Make these swaps in order. Lines are numbered from 1 in each core.

  1. In core enc, swap the operand P1 on line 1 with P0 on line 5.
  2. In core enc, swap the instruction JG on line 1 with IN on line 3.
  3. In core dec, swap the operand K on line 1 with P0 on line 5.
  4. In core dec, swap the operand P1 on line 2 with K on line 5.
  5. In core dec, swap the instruction OUT on line 3 with IN on 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 P1

decSC-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