S23SPLIT DECISION
The task
The sign sorter, swapped about. Swap its pieces back.
Positive values from X go to P and negative ones to Q, in order. Zeros go nowhere.
The board
Key idea
Par is 4 swaps. Core h needs 2 instruction swaps and 2 operand swaps. 2 of them trade two tiles that hold each other's places; look for those first, since one swap mends both.
Hints
Each hint goes a step further than the one before. Open them one at a time.
Hint 1Show
JG jumps when A is above 0, and JL when it is below. A zero falls through both.
Hint 2Show
A value that falls through both jumps is dropped: back to the read.
Hint 3Show
Each leaf only passes values along: IN P0, then OUT P1.
Solution
Reveal the Full SolutionThe complete program for SPLIT DECISION. Open it only when you want the answer.
The board as dealt
This is the arrangement the game deals. Framed tiles are the ones out of place.
hSC-2 standard
T: IN P0
JMP N
JG T
JL T
G: OUT P1
JMP G
N: OUT P2c1SC-2 standard
IN P0
OUT P1c2SC-2 standard
IN P0
OUT P14 swaps back
Make these swaps in order. Lines are numbered from 1 in each core.
- In core
h, swap the operandNon line 2 withGon line 6. - In core
h, swap the operandTon line 3 withNon line 6. - In core
h, swap the instructionJMPon line 2 withJGon line 3. - In core
h, swap the instructionJMPon line 3 withJLon line 4.
The finished program
Every tile back in place: the reference solution, which scores exactly par on every benchmark.
hSC-2 standard
T: IN P0
JG G
JL N
JMP T
G: OUT P1
JMP T
N: OUT P2c1SC-2 standard
IN P0
OUT P1c2SC-2 standard
IN P0
OUT P1- CYCLES
- 198
- at par
- ENERGY
- 1392
- at par
- NODES
- 3
- at par
- INSTRUCTIONS
- 11
- at par
- SWAPS
- 4
- at par