19COMPARATOR
The task
X arrives in pairs. P must receive each pair with the smaller value first.
The stream forks into two paths that meet again at the core on the right.
The board
Key idea
Order a pair: the min goes one way, the max the other, and they join.
Hints
Each hint goes a step further than the one before. Open them one at a time.
Hint 1Show
One path can work out which value is bigger while the other carries the values.
Hint 2Show
MOV B, A then SUB B gives the second value minus the first.
Hint 3Show
To send the second value first, hold the first in B.
Solution
Reveal the Full SolutionThe complete program for COMPARATOR. 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.
c0SC-2 standard
IN P0
OUT P1
OUT P2
IN P0
OUT P1
OUT P2c1SC-2 standard
IN P0
MOV B, A
IN P0
SUB B
OUT P1c2SC-2 standard
IN P0
OUT P1c3SC-2 standard
T: IN P0
JL S
IN P1
OUT P2
IN P1
OUT P2
JMP T
S: IN P1
XCH A, B
IN P1
OUT P2
XCH A, B
OUT P2- CYCLES
- 274
- at par
- ENERGY
- 2558
- at par
- NODES
- 4
- at par
- INSTRUCTIONS
- 26
- at par