Syscall 2: Firmware, home

ShuffleChapter 11: Capstones

S44PILEUP

The task

A four stage line, each stage swapped about. Swaps stay inside a core.

Square X, take 7 away, square that, take 20 away, multiply by 3, and take 1 away.

P must receive the result for each X.

The board

The board of PILEUP4 cores: a, b, c, and d. Inputs X; outputs P.aSC-1 8 LINESbSC-2L 15 LINEScSC-2 15 LINESdSC-1 8 LINESP0P1P0P1P0P1P0P1XP
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 8 swaps. Core c needs 3 instruction swaps and 4 operand swaps; core d needs 1 instruction swap. 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

Each core does some of the steps to every value, in the order the brief gives them.

Hint 2Show

MUL A squares A. A number after MUL or SUB says how much.

Hint 3Show

c does three steps: square, take 20 away, then multiply by 3.

Solution

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

aSC-1 lite

IN P0
MUL A
OUT P1

bSC-2L low power

IN P0
SUB 7
OUT P1

cSC-2 standard

OUT P1
SUB 3
IN P0
MUL 20
MUL A

dSC-1 lite

SUB P0
IN 1
OUT P1

8 swaps back

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

  1. In core c, swap the operand P1 on line 1 with P0 on line 3.
  2. In core c, swap the operand 3 on line 2 with A on line 5.
  3. In core c, swap the operand P1 on line 3 with 20 on line 4.
  4. In core c, swap the operand P1 on line 4 with 3 on line 5.
  5. In core c, swap the instruction OUT on line 1 with IN on line 3.
  6. In core c, swap the instruction SUB on line 2 with MUL on line 5.
  7. In core c, swap the instruction OUT on line 3 with SUB on line 5.
  8. In core d, swap the instruction SUB on line 1 with IN on line 2.

The finished program

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

aSC-1 lite

IN P0
MUL A
OUT P1

bSC-2L low power

IN P0
SUB 7
OUT P1

cSC-2 standard

IN P0
MUL A
SUB 20
MUL 3
OUT P1

dSC-1 lite

IN P0
SUB 1
OUT P1
CYCLES
287
at par
ENERGY
2223
at par
NODES
4
at par
INSTRUCTIONS
14
at par
SWAPS
8
at par