S02MIXED BAG
The task
A working program, swapped about. Put its pieces back where they belong.
P must receive the running total of X. A zero clears the total and sends 0.
The board
Key idea
Par is 3 swaps. Core c1 needs 2 instruction swaps and 1 operand swap. 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
B keeps a value while A reads the next one.
Hint 2Show
ADD B then MOV B, A adds the value to the total and keeps the new total.
Hint 3Show
A line marked in red holds a piece that cannot go there, such as a label where a pin belongs.
Solution
Reveal the Full SolutionThe complete program for MIXED BAG. 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.
c0SC-2 standard
IN P0
OUT P1c1SC-2 standard
ADD P0
JZ N
OUT B
N: MOV B, P1
IN A3 swaps back
Make these swaps in order. Lines are numbered from 1 in each core.
- In core
c1, swap the operandP1on line 4 withAon line 5. - In core
c1, swap the instructionADDon line 1 withINon line 5. - In core
c1, swap the instructionOUTon line 3 withADDon line 5.
The finished program
Every tile back in place: the reference solution, which scores exactly par on every benchmark.
c0SC-2 standard
IN P0
OUT P1c1SC-2 standard
IN P0
JZ N
ADD B
N: MOV B, A
OUT P1- CYCLES
- 230
- at par
- ENERGY
- 1590
- at par
- NODES
- 2
- at par
- INSTRUCTIONS
- 7
- at par
- SWAPS
- 3
- at par