Syscall 2: Firmware, home

SignalChapter 5: Half duplex

38PARTY LINE

The task

Each step names an account on X, from 1 to 3, and an amount on Y.

P must receive that account's new balance. Balances start at 0, and account 1 is nearest.

The board

The board of PARTY LINE4 cores: h, c1, c2, and c3. Inputs X and Y; outputs P.hSC-2 15 LINESc1SC-2 15 LINESc2SC-2 15 LINESc3SC-2 6 LINESP0P1P2P3P0P1P0P1P0XYP
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

Addressed requests down a line of bi hops; each core counts the address down and keeps a balance in B.

Hints

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

Hint 1Show

A core can keep its balance in B and still work in A.

Hint 2Show

Take 1 from the account number at each core. The core that reaches 0 owns it.

Hint 3Show

Send the answer back the way the request came.

Solution

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

IN P0
OUT P2
IN P1
OUT P2
IN P2
OUT P3

c1SC-2 standard

T: IN P0
SUB 1
JZ M
OUT P1
IN P0
OUT P1
IN P1
OUT P0
JMP T
M: IN P0
ADD B
MOV B, A
OUT P0

c2SC-2 standard

T: IN P0
SUB 1
JZ M
OUT P1
IN P0
OUT P1
IN P1
OUT P0
JMP T
M: IN P0
ADD B
MOV B, A
OUT P0

c3SC-2 standard

IN P0
IN P0
ADD B
MOV B, A
OUT P0
CYCLES
727
at par
ENERGY
5086
at par
NODES
4
at par
INSTRUCTIONS
37
at par