Syscall 2: Firmware, home

SignalChapter 12: Shared buses

93SECOND CHANCE

The task

a reads X onto a bus it shares with b and c.

P, on b, must receive the values of X above 0, and Q, on c, the rest, each in order.

The board

The board of SECOND CHANCE3 cores: a, b, and c. Inputs X; outputs P and Q. 1 shared bus.aSC-2 15 LINESbSC-2 6 LINEScSC-2 15 LINESP0P1P0P1P0P1XPQ
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

B keeps what is above 0 and writes the rest back for c, but a writes its next value first unless it rests.

Hints

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

Hint 1Show

b reads first, so it can send on what is above 0 and write the rest back on the bus for c.

Hint 2Show

If a has written its next value by then, c takes a's: the one farther left goes first.

Hint 3Show

a can wait a cycle after each value, so that b's goes out first.

Solution

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

aSC-2 standard

IN P0
OUT P1
NOP

bSC-2 standard

S: IN P0
JG K
OUT P0
JMP S
K: OUT P1

cSC-2 standard

IN P0
OUT P1
CYCLES
182
at par
ENERGY
1764
at par
NODES
3
at par
INSTRUCTIONS
10
at par