Syscall 2: Firmware, home

ShuffleChapter 9: Special nodes

S34SAY AGAIN

The task

Both ends of a lossy line, swapped about. Swaps stay inside a core.

P must receive a copy of X, from 1 to 99.

The locked line turns every third value it carries into a 0.

The board

The board of SAY AGAIN3 cores: tx, ln, and rx. Locked: ln. Inputs X; outputs P.txSC-2 15 LINESlnLOCKEDS: IN P0XCHJZ DNSUB 1XCHOUT P1JMP SDN: ADD 2MOV B, ASUB BOUT P1rxSC-2 5 LINESP0P1P2P0P1P0P1P2XP
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 tx needs 2 instruction swaps and 1 operand swap; core rx needs 2 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

rx tells a lost value by its 0 and answers tx with whatever it got.

Hint 2Show

tx keeps the value in B and sends it again while the answer is 0.

Hint 3Show

rx passes a value on to P only once it is not 0.

Solution

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

txSC-2 standard

IN P0
MOV B, A
R: MOV P2, B
JZ P1
OUT A
IN R

rxSC-2 standard

S: OUT P2
OUT P0
IN S
JZ P1

6 swaps back

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

  1. In core tx, swap the operand P2 on line 3 with A on line 5.
  2. In core tx, swap the instruction JZ on line 4 with OUT on line 5.
  3. In core tx, swap the instruction JZ on line 5 with IN on line 6.
  4. In core rx, swap the operand P2 on line 1 with P0 on line 2.
  5. In core rx, swap the instruction OUT on line 1 with IN on line 3.
  6. In core rx, swap the instruction OUT on line 3 with JZ on line 4.

The finished program

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

txSC-2 standard

IN P0
MOV B, A
R: MOV A, B
OUT P1
IN P2
JZ R

rxSC-2 standard

S: IN P0
OUT P2
JZ S
OUT P1
CYCLES
809
at par
ENERGY
3180
at par
NODES
2
at par
INSTRUCTIONS
10
at par
SWAPS
6
at par