Syscall 2: Firmware, home

SignalChapter 7: Frames and loops

55LEVEL

The task

X is a stream of frames of 1 to 3 values from -15 to 15, each ended by a 0.

P must receive each value minus the smallest value in its frame. No 0 goes to P.

The board

The board of LEVEL5 cores: m, q1, q2, q3, and q4. Inputs X; outputs P.mSC-2 15 LINESq1SC-2 15 LINESq2SC-2 15 LINESq3SC-2 15 LINESq4SC-2 15 LINESP0P1P2P3P0P1P0P1P0P1P0P1XP
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

The smallest is only known at the end, so the frame waits in the loop and is read back.

Hints

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

Hint 1Show

The smallest value is only known at the end of the frame, so store the frame first.

Hint 2Show

Keep the smallest so far in B. Start it above anything X can send.

Hint 3Show

Send the 0 round too, so you know when the stored frame has come home.

Solution

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

mSC-2 standard

R: MOV A, 100
MOV B, A
S: IN P0
OUT P2
JZ L
SUB B
JG S
ADD B
MOV B, A
JMP S
L: IN P3
JZ R
SUB B
OUT P1
JMP L

q1SC-2 standard

IN P0
OUT P1

q2SC-2 standard

IN P0
OUT P1

q3SC-2 standard

IN P0
OUT P1

q4SC-2 standard

IN P0
OUT P1
CYCLES
453
at par
ENERGY
3996
at par
NODES
5
at par
INSTRUCTIONS
23
at par