S21ROUGH EDGES
The task
The edge detector, swapped about. Swap its pieces back.
P must receive 1 when a value is 10 or more away from the one before it, else 0.
The value before the first is 0.
The board
Key idea
Par is 4 swaps. Core c2 needs 2 instruction swaps and 2 operand swaps. 3 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
XCH after IN keeps the new value in B and brings the old one into A.
Hint 2Show
JG skips the NEG when the difference is already positive.
Hint 3Show
After SUB 10, a negative result means the step was small: send 0.
Solution
Reveal the Full SolutionThe complete program for ROUGH EDGES. 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
c2SC-2 standard
T: IN P0
XCH A, B
SUB 1
OUT P2
NEG
G: SUB 10
JG N
MOV A, B
OUT P2
JMP T
N: MOV A, 0
JL G4 swaps back
Make these swaps in order. Lines are numbered from 1 in each core.
- In core
c2, swap the operand1on line 3 withBon line 8. - In core
c2, swap the operandP2on line 4 withGon line 12. - In core
c2, swap the instructionOUTon line 4 withJGon line 7. - In core
c2, swap the instructionOUTon line 7 withJLon line 12.
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
c2SC-2 standard
T: IN P0
XCH A, B
SUB B
JG G
NEG
G: SUB 10
JL N
MOV A, 1
OUT P2
JMP T
N: MOV A, 0
OUT P2- CYCLES
- 401
- at par
- ENERGY
- 2606
- at par
- NODES
- 2
- at par
- INSTRUCTIONS
- 14
- at par
- SWAPS
- 4
- at par