Syscall 2: Firmware, home

SignalChapter 4: Stars and hubs

23SELECTOR

The task

When X is 0, P takes the next Y. Otherwise P takes the next Z.

Both streams are used up either way. Only the hub sees X, and Z can be zero too.

The board

The board of SELECTOR3 cores: h, c2, and c1. Inputs X, Y, and Z; outputs P.hSC-2 15 LINESc2SC-2 4 LINESc1SC-2 15 LINESP0P1P2P0P1P0P1P2XZYP
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

Multiplex with a flag word, since any value can be data; drain the unused stream.

Hints

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

Hint 1Show

The output core cannot tell a choice from a value unless you tell it which is which.

Hint 2Show

Send X on first as the flag, then the value if there is one.

Hint 3Show

A value nobody picked still has to be read, or the streams fall out of step.

Solution

Reveal the Full SolutionThe complete program for SELECTOR. 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
OUT P1
JZ N
IN P2
OUT P1
JMP T
N: IN P2

c2SC-2 standard

IN P0
OUT P1

c1SC-2 standard

T: IN P2
JZ N
IN P0
IN P2
OUT P1
JMP T
N: IN P0
OUT P1
CYCLES
275
at par
ENERGY
2888
at par
NODES
3
at par
INSTRUCTIONS
17
at par