47BUTTERFLY
The task
P must receive the largest of X, Y, Z, and W minus the smallest.
Each middle core can reach both of the cores on the right.
The board
Key idea
Sort each pair, then send winners one way and losers the other on crossing wires; the low root hands its answer to the high one.
Hints
Each hint goes a step further than the one before. Open them one at a time.
Hint 1Show
Sort each pair into its larger and smaller value.
Hint 2Show
The winners go one way and the losers the other.
Hint 3Show
One compare can give both answers if the first value stays in B.
Solution
Reveal the Full SolutionThe complete program for BUTTERFLY. 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.
fSC-2 standard
IN P0
OUT P4
IN P1
OUT P4
IN P2
OUT P5
IN P3
OUT P5nbSC-2 standard
IN P0
MOV B, A
IN P0
SUB B
JG L
ADD B
XCH A, B
JMP O
L: ADD B
O: OUT P1
MOV A, B
OUT P2ndSC-2 standard
IN P0
MOV B, A
IN P0
SUB B
JG L
ADD B
XCH A, B
JMP O
L: ADD B
O: OUT P1
MOV A, B
OUT P2rxSC-2 standard
IN P0
MOV B, A
IN P1
SUB B
JG K
MOV A, 0
K: ADD B
MOV B, A
IN P2
NEG
ADD B
OUT P3rySC-2 standard
IN P0
MOV B, A
IN P1
SUB B
JL K
MOV A, 0
K: ADD B
OUT P2- CYCLES
- 661
- at par
- ENERGY
- 11038
- at par
- NODES
- 5
- at par
- INSTRUCTIONS
- 52
- at par