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
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 P1c1SC-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 P2c2SC-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