S26JUNK DRAWER
The task
The directory clerk's code, swapped about. Swap it back.
For each index 0 to 5 on X, P must receive that entry of the directory.
Entries 0 to 2 sit in the left drawer, 3 to 5 in the right. Each counts from 0.
The board
Key idea
Par is 5 swaps. Core h needs 1 instruction swap and 4 operand swaps. 4 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
SUB 3 tells the drawers apart: below 0 is the left drawer.
Hint 2Show
The right drawer's 0 is entry 3, so it gets the index less 3. ADD 3 undoes it for the left.
Hint 3Show
Ask a drawer, read its answer on the same pin, then send it to P.
Solution
Reveal the Full SolutionThe complete program for JUNK DRAWER. 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 P2
SUB P1
OUT P3
OUT 3
IN P0
JL P3
JMP T
L: ADD 3
OUT P2
IN P1
OUT L5 swaps back
Make these swaps in order. Lines are numbered from 1 in each core.
- In core
h, swap the operandP2on line 1 withP0on line 5. - In core
h, swap the operandP3on line 3 withLon line 11. - In core
h, swap the operandP1on line 2 with3on line 4. - In core
h, swap the operandP1on line 4 withP2on line 9. - In core
h, swap the instructionOUTon line 3 withJLon line 6.
The finished program
Every tile back in place: the reference solution, which scores exactly par on every benchmark.
hSC-2 standard
T: IN P0
SUB 3
JL L
OUT P2
IN P2
OUT P3
JMP T
L: ADD 3
OUT P1
IN P1
OUT P3- CYCLES
- 519
- at par
- ENERGY
- 1636
- at par
- NODES
- 1
- at par
- INSTRUCTIONS
- 11
- at par
- SWAPS
- 5
- at par