Syscall 2: Firmware, home

ShuffleChapter 8: Scarcity

S30BACKCHAT

The task

Two cores on one wire, their pieces swapped. Swaps stay inside a core.

P on the left must receive X plus Y. Q on the right must receive Y minus X.

The board

The board of BACKCHAT2 cores: left and right. Inputs X and Y; outputs P and Q.leftSC-2 8 LINESrightSC-2 15 LINESP0P1P2P0P1P2XYPQ
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 6 swaps. Core left needs 2 operand swaps; core right needs 3 instruction swaps and 1 operand swap. 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

The right core speaks first and the left one listens, then they trade places.

Hint 2Show

The left core sends back the sum, not what it read.

Hint 3Show

From the sum, taking Y away twice and flipping the sign leaves Y minus X.

Solution

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

leftSC-2 standard

IN P2
MOV A, B
IN P0
ADD B
OUT P1
OUT P1

rightSC-2 standard

OUT P0
OUT P1
IN A
MOV B, B
IN P1
ADD A
NEG
SUB P2

6 swaps back

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

  1. In core left, swap the operand P2 on line 1 with P1 on line 5.
  2. In core left, swap the operand A on line 2 with B on line 2.
  3. In core right, swap the operand B on line 4 with A on line 6.
  4. In core right, swap the instruction OUT on line 1 with IN on line 3.
  5. In core right, swap the instruction OUT on line 3 with ADD on line 6.
  6. In core right, swap the instruction OUT on line 6 with SUB on line 8.

The finished program

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

leftSC-2 standard

IN P1
MOV B, A
IN P0
ADD B
OUT P2
OUT P1

rightSC-2 standard

IN P0
OUT P1
ADD A
MOV B, A
IN P1
SUB B
NEG
OUT P2
CYCLES
547
at par
ENERGY
3276
at par
NODES
2
at par
INSTRUCTIONS
14
at par
SWAPS
6
at par