Syscall 2: Firmware, home

SignalChapter 7: Frames and loops

49LEADER

The task

Three stations stand in a ring, and each one hears its own stream.

P and Q must each receive the largest of X, Y and Z.

The board

The board of LEADER3 cores: a, b, and c. Inputs X, Y, and Z; outputs P and Q.aSC-2 15 LINESbSC-2 15 LINEScSC-2 15 LINESP0P1P2P3P0P1P2P3P0P1P2XPYQZ
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 value goes round a ring, picking up the largest, and the answer comes back round to the first two stations.

Hints

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

Hint 1Show

Pass the largest so far round the ring, one station at a time.

Hint 2Show

The last station knows the answer, and the ring brings it back to the others.

Hint 3Show

If every station writes before it reads, the ring stops dead.

Solution

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

aSC-2 standard

IN P0
OUT P2
IN P3
OUT P1
OUT P2

bSC-2 standard

IN P0
MOV B, A
IN P2
SUB B
JL L
ADD B
MOV B, A
L: MOV A, B
OUT P3
IN P2
OUT P1

cSC-2 standard

IN P0
MOV B, A
IN P1
SUB B
JL L
ADD B
MOV B, A
L: MOV A, B
OUT P2
CYCLES
836
at par
ENERGY
5466
at par
NODES
3
at par
INSTRUCTIONS
25
at par