S20HIGH TIDE
The task
Two copies of one core, each with its pieces swapped. Swaps stay inside a core.
P must receive the largest of each value from X and the two before it.
Count 0 before the start.
The board
Key idea
Par is 4 swaps. Core c1 needs 1 instruction swap and 1 operand swap; core c2 needs 1 instruction swap and 1 operand swap. Every one of them trades two tiles that hold each other's places, so each swap mends two.
Hints
Each hint goes a step further than the one before. Open them one at a time.
Hint 1Show
Each core sends the larger of a value and the one before it. Two in a row make three.
Hint 2Show
XCH keeps the new value in B and brings the old one into A.
Hint 3Show
After SUB B, a gap of 0 or less means the new value wins: clear A, and ADD B brings it back.
Solution
Reveal the Full SolutionThe complete program for HIGH TIDE. 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
IN P0
XCH A, B
ADD B
JG K
MOV B, 0
K: SUB A
OUT P1c2SC-2 standard
IN P0
XCH A, B
SUB B
JG K
MOV A, 0
K: OUT P1
ADD B4 swaps back
Make these swaps in order. Lines are numbered from 1 in each core.
- In core
c1, swap the operandBon line 5 withAon line 6. - In core
c1, swap the instructionADDon line 3 withSUBon line 6. - In core
c2, swap the operandP1on line 6 withBon line 7. - In core
c2, swap the instructionOUTon line 6 withADDon line 7.
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
XCH A, B
SUB B
JG K
MOV A, 0
K: ADD B
OUT P1c2SC-2 standard
IN P0
XCH A, B
SUB B
JG K
MOV A, 0
K: ADD B
OUT P1- CYCLES
- 319
- at par
- ENERGY
- 3542
- at par
- NODES
- 3
- at par
- INSTRUCTIONS
- 16
- at par
- SWAPS
- 4
- at par