Syscall 2: Firmware, home

SignalChapter 4: Stars and hubs

27TICKET OFFICE

The task

X brings a queue of 0, 1, and 2. For each, P must receive that number's ticket count so far.

Two clerks keep counts on request, and the office keeps the third.

The board

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

Counters on request, one kept in B at the hub; ANY would take the next input instead of the reply.

Hints

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

Hint 1Show

Each clerk keeps its count in B. So does the office.

Hint 2Show

Ask a clerk by sending it anything, then read its answer.

Hint 3Show

Read the answer from the clerk you asked.

Solution

Reveal the Full SolutionThe complete program for TICKET 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
JZ N
SUB 1
JZ O
OUT P3
IN P3
JMP F
O: MOV A, 1
OUT P2
IN P2
JMP F
N: MOV A, 1
ADD B
MOV B, A
F: OUT P1

c1SC-2 standard

IN P0
ADD B
MOV B, A
OUT P0

c2SC-2 standard

IN P0
ADD B
MOV B, A
OUT P0
CYCLES
445
at par
ENERGY
2340
at par
NODES
3
at par
INSTRUCTIONS
23
at par