Syscall 2: Firmware, home

SignalChapter 4: Stars and hubs

28WINNER

The task

P must receive which of X, Y, and Z is largest: 0, 1, or 2.

On a tie the earlier stream wins.

The board

The board of WINNER3 cores: sb, c1, and c2. Inputs X, Y, and Z; outputs P.sbSC-2 4 LINESc1SC-2 15 LINESc2SC-2 15 LINESP0P1P0P1P2P0P1P2YXZP
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

Argmax of three streams; a compared value is used up, so one stream is sent twice.

Hints

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

Hint 1Show

MOV B, A keeps a value in B, so SUB B compares without losing it.

Hint 2Show

After SUB B, ADD B gives the value in A back.

Hint 3Show

Pass on the leader's number and its value. Z is only compared once.

Solution

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

sbSC-2 standard

IN P0
OUT P1

c1SC-2 standard

IN P1
MOV B, A
IN P0
SUB B
JL H
ADD B
OUT P2
MOV A, 0
JMP O
H: MOV A, B
OUT P2
MOV A, 1
O: OUT P2

c2SC-2 standard

T: IN P0
MOV B, A
IN P1
SUB B
JG H
IN P0
JMP O
H: IN P0
MOV A, 2
O: OUT P2
CYCLES
513
at par
ENERGY
4564
at par
NODES
3
at par
INSTRUCTIONS
25
at par