S35HAREBRAINED
The task
The rabbit counter, swapped about. Swaps stay inside a core.
P must receive Fibonacci number X, where X is from 1 to 11.
The numbers go 1, 1, 2, 3, 5, 8 and so on, each the sum of the two before it.
The board
Key idea
Par is 7 swaps. Core f needs 2 instruction swaps and 5 operand swaps. 5 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
f keeps the count in B and the number in A, and XCH trades them.
Hint 2Show
g keeps the last number it saw in B. XCH then ADD B gives the next one.
Hint 3Show
f sends g a 0 first, so g starts each X from nothing.
Solution
Reveal the Full SolutionThe complete program for HAREBRAINED. 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.
fSC-2 standard
IN P0
SUB 1
MOV 1, A
IN B
OUT DN
MOV A, B
L: XCH A, B
SUB B
JZ 1
XCH L, P2
OUT P2
SUB A
JMP P3
DN: XCH A, B
OUT P1gSC-2 standard
S: IN P0
JZ R
XCH A, B
ADD B
OUT P1
JMP S
R: MOV B, A7 swaps back
Make these swaps in order. Lines are numbered from 1 in each core.
- In core
f, swap the operand1on line 3 withBon line 6. - In core
f, swap the operandDNon line 5 withP2on line 10. - In core
f, swap the operandBon line 8 withDNon line 10. - In core
f, swap the operandLon line 10 withAon line 12. - In core
f, swap the operandLon line 12 withP3on line 13. - In core
f, swap the instructionINon line 4 withSUBon line 12. - In core
f, swap the instructionSUBon line 8 withJZon line 9.
The finished program
Every tile back in place: the reference solution, which scores exactly par on every benchmark.
fSC-2 standard
IN P0
SUB 1
MOV B, A
SUB B
OUT P2
MOV A, 1
L: XCH A, B
JZ DN
SUB 1
XCH A, B
OUT P2
IN P3
JMP L
DN: XCH A, B
OUT P1gSC-2 standard
S: IN P0
JZ R
XCH A, B
ADD B
OUT P1
JMP S
R: MOV B, A- CYCLES
- 925
- at par
- ENERGY
- 5772
- at par
- NODES
- 2
- at par
- INSTRUCTIONS
- 22
- at par
- SWAPS
- 7
- at par