Syscall 2: Firmware, home

SignalChapter 7: Frames and loops

53REPLAY

The task

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

P must receive each frame with its 0, and then the same frame again.

The board

The board of REPLAY5 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

A loop of relays is a memory: a frame goes in, comes back round, and is sent again.

Hints

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

Hint 1Show

A value stays in a relay until the next core takes it, so the loop is a store.

Hint 2Show

Send the frame round the loop as it goes out to P, the 0 as well.

Hint 3Show

When the frame has gone round, read it back until its 0 comes home.

Solution

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

S: IN P0
OUT P1
OUT P2
JNZ S
L: IN P3
OUT P1
JNZ 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
202
at par
ENERGY
1644
at par
NODES
5
at par
INSTRUCTIONS
15
at par