S48SQUARE ONE
The task
A square root, swapped about. Every piece is out of place.
X is from 0 to 121. P must receive its whole square root: 15 sends 3, and 16 sends 4.
The board
Key idea
Par is 10 swaps. Core a needs 3 instruction swaps and 6 operand swaps; core b needs 1 instruction swap. 9 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
Start from a guess above the root: X divided by 20, plus 6.
Hint 2Show
The average of a guess and X divided by it is a closer guess.
Hint 3Show
Stop once a new guess is no smaller than the last, and send the last one.
Solution
Reveal the Full SolutionThe complete program for SQUARE ONE. 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.
aSC-4 quad
OUT A
MOV K, A
DIV P1
JMP 6
ADD 2
K: ADD C
L: MOV B, P0
MOV A, A
DIV C
DIV C
ADD L
SUB C
JL B
MOV C, C
IN 20bSC-2D signal processor
OUT P0
IN P1cSC-2L low power
IN P0
OUT P110 swaps back
Make these swaps in order. Lines are numbered from 1 in each core.
- In core
a, swap the operandAon line 1 withP0on line 7. - In core
a, swap the operandKon line 2 withBon line 13. - In core
a, swap the operandP1on line 3 with20on line 15. - In core
a, swap the operand2on line 5 withLon line 11. - In core
a, swap the operandBon line 7 withCon line 14. - In core
a, swap the operandAon line 8 withBon line 14. - In core
a, swap the instructionOUTon line 1 withINon line 15. - In core
a, swap the instructionJMPon line 4 withADDon line 5. - In core
a, swap the instructionDIVon line 10 withADDon line 11. - In core
b, swap the instructionOUTon line 1 withINon line 2.
The finished program
Every tile back in place: the reference solution, which scores exactly par on every benchmark.
aSC-4 quad
IN P0
MOV B, A
DIV 20
ADD 6
JMP L
K: ADD C
L: MOV C, A
MOV A, B
DIV C
ADD C
DIV 2
SUB C
JL K
MOV A, C
OUT P1bSC-2D signal processor
IN P0
OUT P1cSC-2L low power
IN P0
OUT P1- CYCLES
- 999
- at par
- ENERGY
- 9024
- at par
- NODES
- 3
- at par
- INSTRUCTIONS
- 19
- at par
- SWAPS
- 10
- at par