Syscall 2: Firmware, home

SignalChapter 4: Stars and hubs

24SORTING OFFICE

The task

Each Y parcel has an address on X: 1 sends it to P, 2 to Q, 3 to both.

New: JRX A jumps ahead by the value in A.

The board

The board of SORTING OFFICE3 cores: h, c1, and c2. Inputs X and Y; outputs P and Q.hSC-2 15 LINESc1SC-2 15 LINESc2SC-2 15 LINESP0P1P2P3P0P1P0P1XYPQ
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

Demultiplex by address with JRX A once IN has the address; address 3 goes to both.

Hints

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

Hint 1Show

IN P0 reads the address, and JRX A jumps that many lines ahead.

Hint 2Show

Put a JMP on each of the lines it can land on.

Hint 3Show

Address 3 needs the parcel twice, and OUT leaves A as it was.

Solution

Reveal the Full SolutionThe complete program for SORTING OFFICE. Open it only when you want the answer.

The reference program

The game's own solution. It passes every test and scores exactly par on every benchmark.

hSC-2 standard

T: IN P0
JRX A
JMP F
JMP U
IN P1
OUT P3
JMP H
U: IN P1
OUT P3
JMP T
F: IN P1
H: OUT P2

c1SC-2 standard

IN P0
OUT P1

c2SC-2 standard

IN P0
OUT P1
CYCLES
277
at par
ENERGY
1934
at par
NODES
3
at par
INSTRUCTIONS
16
at par

Another way: Branches

A second program that also passes, by a different road, at a cost on CYCLES and ENERGY.

Plain tests instead of JRX.

hSC-2 standard

T: IN P0
SUB 2
JZ U
JL F
IN P1
OUT P3
JMP H
U: IN P1
OUT P3
JMP T
F: IN P1
H: OUT P2

c1SC-2 standard

IN P0
OUT P1

c2SC-2 standard

IN P0
OUT P1
CYCLES
315
over par
ENERGY
2160
over par
NODES
3
at par
INSTRUCTIONS
16
at par