24SORTING OFFICE
The task
Each Y parcel has an address on X: 1 sends it to P, 2 to Q, 3 to both.
New: JRX A jumps ahead by the value in A.
The board
Key idea
Demultiplex by address with JRX A once IN has the address; address 3 goes to both.
Hints
Each hint goes a step further than the one before. Open them one at a time.
Hint 1Show
IN P0 reads the address, and JRX A jumps that many lines ahead.
Hint 2Show
Put a JMP on each of the lines it can land on.
Hint 3Show
Address 3 needs the parcel twice, and OUT leaves A as it was.
Solution
Reveal the Full SolutionThe complete program for SORTING OFFICE. 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.
hSC-2 standard
T: IN P0
JRX A
JMP F
JMP U
IN P1
OUT P3
JMP H
U: IN P1
OUT P3
JMP T
F: IN P1
H: OUT P2c1SC-2 standard
IN P0
OUT P1c2SC-2 standard
IN P0
OUT P1- CYCLES
- 277
- at par
- ENERGY
- 1934
- at par
- NODES
- 3
- at par
- INSTRUCTIONS
- 16
- at par
Another way: Branches
A second program that also passes, by a different road, at a cost on CYCLES and ENERGY.
Plain tests instead of JRX.
hSC-2 standard
T: IN P0
SUB 2
JZ U
JL F
IN P1
OUT P3
JMP H
U: IN P1
OUT P3
JMP T
F: IN P1
H: OUT P2c1SC-2 standard
IN P0
OUT P1c2SC-2 standard
IN P0
OUT P1- CYCLES
- 315
- over par
- ENERGY
- 2160
- over par
- NODES
- 3
- at par
- INSTRUCTIONS
- 16
- at par