Syscall 2: Firmware, home

ShuffleChapter 5: Half duplex

S12FLIP GATE

The task

A working program, swapped about. Restore each core.

Every value from X must reach P with its sign flipped.

The board

The board of FLIP GATE2 cores: a and b. Inputs X; outputs P.aSC-2 15 LINESbSC-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 2 swaps. Core a needs 1 operand swap; core b needs 1 instruction swap. Every one of them trades two tiles that hold each other's places, so each swap mends two.

Hints

Each hint goes a step further than the one before. Open them one at a time.

Hint 1Show

NEG flips the sign of A. It belongs between the read and the write.

Hint 2Show

Core b only passes the value along: IN P0, then OUT P1.

Hint 3Show

Pieces swap inside one core. A line from b cannot land in a.

Solution

Reveal the Full SolutionThe complete program for FLIP GATE. 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-2 standard

IN P1
NEG
OUT P0

bSC-2 standard

OUT P0
IN P1

2 swaps back

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

  1. In core a, swap the operand P1 on line 1 with P0 on line 3.
  2. In core b, swap the instruction OUT 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-2 standard

IN P0
NEG
OUT P1

bSC-2 standard

IN P0
OUT P1
CYCLES
159
at par
ENERGY
1170
at par
NODES
2
at par
INSTRUCTIONS
5
at par
SWAPS
2
at par