Syscall 2: Firmware, home

ShuffleChapter 10: Meshes

S38TIGHT SQUEEZE

The task

The clamp, swapped about. Swap its pieces back.

P must receive each X held between -20 and 60: lower values become -20, higher ones 60.

The board

The board of TIGHT SQUEEZE2 cores: c and h. Inputs X; outputs P.cSC-1 8 LINEShSC-2 15 LINESP0P1P0P1XP
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 7 swaps. Core h needs 3 instruction swaps and 4 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

SUB 60 puts the top of the range at 0, and a value still above 0 is cut to 0.

Hint 2Show

ADD 80 then puts the bottom of the range at 0, and a value below it is cut to 0.

Hint 3Show

SUB 20 brings the value back to where it belongs.

Solution

Reveal the Full SolutionThe complete program for TIGHT SQUEEZE. 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.

cSC-1 lite

IN P0
OUT P1

hSC-2 standard

JL P0
IN 60
ADD 20
MOV 0, P1
L: SUB 0
JG G
MOV A, 80
G: SUB L
OUT A

7 swaps back

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

  1. In core h, swap the operand 20 on line 3 with L on line 8.
  2. In core h, swap the operand 0 on line 5 with 80 on line 7.
  3. In core h, swap the operand 0 on line 4 with A on line 9.
  4. In core h, swap the operand P1 on line 4 with 0 on line 9.
  5. In core h, swap the instruction JL on line 1 with IN on line 2.
  6. In core h, swap the instruction JL on line 2 with SUB on line 5.
  7. In core h, swap the instruction ADD on line 3 with JL on line 5.

The finished program

Every tile back in place: the reference solution, which scores exactly par on every benchmark.

cSC-1 lite

IN P0
OUT P1

hSC-2 standard

IN P0
SUB 60
JL L
MOV A, 0
L: ADD 80
JG G
MOV A, 0
G: SUB 20
OUT P1
CYCLES
332
at par
ENERGY
1970
at par
NODES
2
at par
INSTRUCTIONS
11
at par
SWAPS
7
at par