S47HAILSTORM
The task
The hailstone counter, swapped about. Swaps stay inside a core.
A step halves an even number and takes an odd one to 3 times it plus 1.
X is from 1 to 28. P must receive the steps X takes to reach 1.
The board
Key idea
Par is 9 swaps. Core t needs 1 instruction swap and 1 operand swap; core c needs 3 instruction swaps and 4 operand swaps. 8 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
t looks for 1 before each step, keeps the count in B, and sends each number to c.
Hint 2Show
c keeps the number in B, since MOD 2 leaves only 0 or 1 in A.
Hint 3Show
SUB 1 then JZ finds the 1, and ADD 1 puts the number back when it is not.
Solution
Reveal the Full SolutionThe complete program for HAILSTORM. 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.
tSC-2L low power
S: IN P0
L: SUB 1
JZ F
ADD 1
OUT P1
XCH A, B
ADD 1
MOV B, A
JMP P2
IN B
F: XCH A, L
OUT P3cSC-2 standard
S: JMP S
MOV B, A
MOD 2
MUL P1
MOV A, B
JZ 3
OUT 1
OUT P1
IN P0
E: MOV B, 2
DIV A
ADD E9 swaps back
Make these swaps in order. Lines are numbered from 1 in each core.
- In core
t, swap the operandBon line 10 withLon line 11. - In core
t, swap the instructionJMPon line 9 withINon line 10. - In core
c, swap the operandSon line 1 withP0on line 9. - In core
c, swap the operandP1on line 4 withEon line 12. - In core
c, swap the operandBon line 10 withAon line 11. - In core
c, swap the operand2on line 10 withBon line 11. - In core
c, swap the instructionJMPon line 1 withINon line 9. - In core
c, swap the instructionMULon line 4 withJZon line 6. - In core
c, swap the instructionOUTon line 7 withADDon line 12.
The finished program
Every tile back in place: the reference solution, which scores exactly par on every benchmark.
tSC-2L low power
S: IN P0
L: SUB 1
JZ F
ADD 1
OUT P1
XCH A, B
ADD 1
MOV B, A
IN P2
JMP L
F: XCH A, B
OUT P3cSC-2 standard
S: IN P0
MOV B, A
MOD 2
JZ E
MOV A, B
MUL 3
ADD 1
OUT P1
JMP S
E: MOV A, B
DIV 2
OUT P1- CYCLES
- 3178
- at par
- ENERGY
- 10528
- at par
- NODES
- 2
- at par
- INSTRUCTIONS
- 24
- at par
- SWAPS
- 9
- at par