S08TANGLE
The task
A quad core program, out of order. More than one arrangement sums the window.
P must receive the sum of the last four X values, with zeros before the first one.
The board
Key idea
Par is 5 swaps. Core win needs 2 instruction swaps and 3 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
Three swaps in a row move every value one register along, and A ends with the oldest.
Hint 2Show
ADD B, ADD C, and ADD D read the registers without changing them.
Hint 3Show
Any arrangement that passes the tests solves the puzzle, not only one.
Solution
Reveal the Full SolutionThe complete program for TANGLE. 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.
winSC-4 quad
ADD P0
XCH A, D
XCH C, C
XCH A, P1
OUT B
IN A
ADD D
ADD B5 swaps back
Make these swaps in order. Lines are numbered from 1 in each core.
- In core
win, swap the operandCon line 3 withAon line 6. - In core
win, swap the operandDon line 2 withBon line 8. - In core
win, swap the operandP1on line 4 withDon line 8. - In core
win, swap the instructionADDon line 1 withINon line 6. - In core
win, swap the instructionOUTon line 5 withADDon line 8.
The finished program
Every tile back in place: the reference solution, which scores exactly par on every benchmark.
winSC-4 quad
IN P0
XCH A, B
XCH A, C
XCH A, D
ADD B
ADD C
ADD D
OUT P1- CYCLES
- 352
- at par
- ENERGY
- 2808
- at par
- NODES
- 1
- at par
- INSTRUCTIONS
- 8
- at par
- SWAPS
- 5
- 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.
winSC-4 quad
IN P0
XCH B, A
XCH A, C
XCH A, D
ADD B
ADD C
ADD D
OUT P1- CYCLES
- 352
- at par
- ENERGY
- 2808
- at par
- NODES
- 1
- at par
- INSTRUCTIONS
- 8
- at par
- SWAPS
- 6
- over par