S10LOOSE CHANGE
The task
The meter driver, all of it here and none of it in place.
The locked meter adds each value it gets, writes its total to P, and sends the total back.
P must show the running total of X, back to 0 after each 0.
The board
Key idea
Par is 7 swaps. Core feed needs 3 instruction swaps and 4 operand swaps. 5 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
The meter can only add. To bring its total to 0, send the total with its sign flipped.
Hint 2Show
Keep the last total the meter sent back in B.
Hint 3Show
Read the meter answer before you send the next value.
Solution
Reveal the Full SolutionThe complete program for LOOSE CHANGE. 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.
feedSC-2 standard
T: OUT N
IN P1
JZ A
OUT B
MOV P1, A
JMP T
N: XCH P1, B
NEG
IN P0
IN P17 swaps back
Make these swaps in order. Lines are numbered from 1 in each core.
- In core
feed, swap the operandAon line 3 withP1on line 7. - In core
feed, swap the operandBon line 4 withP1on line 5. - In core
feed, swap the operandNon line 1 withP0on line 9. - In core
feed, swap the operandP1on line 2 withNon line 9. - In core
feed, swap the instructionOUTon line 1 withINon line 9. - In core
feed, swap the instructionINon line 2 withJZon line 3. - In core
feed, swap the instructionINon line 3 withOUTon line 4.
The finished program
Every tile back in place: the reference solution, which scores exactly par on every benchmark.
feedSC-2 standard
T: IN P0
JZ N
OUT P1
IN P1
MOV B, A
JMP T
N: XCH A, B
NEG
OUT P1
IN P1- CYCLES
- 426
- at par
- ENERGY
- 1386
- at par
- NODES
- 1
- at par
- INSTRUCTIONS
- 10
- at par
- SWAPS
- 7
- at par
Another way: Swap a b
A second program that also passes, by a different road, at a cost on SWAPS.
Another arrangement that passes, one swap from the reference.
feedSC-2 standard
T: IN P0
JZ N
OUT P1
IN P1
MOV B, A
JMP T
N: XCH B, A
NEG
OUT P1
IN P1- CYCLES
- 426
- at par
- ENERGY
- 1386
- at par
- NODES
- 1
- at par
- INSTRUCTIONS
- 10
- at par
- SWAPS
- 8
- over par