Syscall 2: Firmware, home

SignalChapter 5: Half duplex

34ORDER DESK

The task

Each value of Y is an order for that many values of X, from 1 to 3.

P must receive the sum of each order. The desk takes orders and the stock room holds X.

The board

The board of ORDER DESK2 cores: s and d. Inputs X and Y; outputs P.sSC-2 15 LINESdSC-2 5 LINESP0P1P0P1P2XYP
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

A counted request: the reply is the sum of that many values, count in B.

Hints

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

Hint 1Show

The stock room cannot see Y, so send it the count.

Hint 2Show

JRX can jump into a run of reads, so a count from 1 to 3 needs no loop.

Hint 3Show

Send the sum back on the same wire.

Solution

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

dSC-2 standard

IN P0
OUT P1
IN P1
OUT P2

sSC-2 standard

T: MOV A, 0
MOV B, A
IN P1
JRX A
JMP A1
JMP A2
IN P0
ADD B
MOV B, A
A2: IN P0
ADD B
MOV B, A
A1: IN P0
ADD B
OUT P1
CYCLES
290
at par
ENERGY
1726
at par
NODES
2
at par
INSTRUCTIONS
19
at par