S45TOP SHELF
The task
Peak hold, with every piece of the program out of place.
While the clock on P1 is low, keep the highest reading of P0.
At each rising edge, write that peak to P2 and start over.
The board
- Sources
- V1 2.5 V, V2 2 V sine at 25 Hz, and V3 5 V square at 125 Hz
- Resistors
- R1 1 kΩ
- Capacitors
- C1 1 µF
- Probes
- CH1, CH2, and CH3
Key idea
Par is 8 swaps. Core u1 needs 3 instruction swaps and 5 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
SUB B compares a reading with the peak in B, and ADD B gives the reading back.
Hint 2Show
A reading under the peak skips straight to the clock check.
Hint 3Show
After the write, clear B and wait for the clock to fall.
Solution
Reveal the Full SolutionThe complete program for TOP SHELF. 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.
u1SC-2 standard
L: IN B
SUB B
JZ K
ADD A
MOV B, A
K: IN P0
OUT H
MOV B, B
IN P2
MOV A, 0
MOV P1, A
H: JL L
JNZ P18 swaps back
Make these swaps in order. Lines are numbered from 1 in each core.
- In core
u1, swap the operandAon line 4 withBon line 8. - In core
u1, swap the operandBon line 1 withP0on line 6. - In core
u1, swap the operandBon line 6 withP1on line 11. - In core
u1, swap the operandHon line 7 withLon line 12. - In core
u1, swap the operandHon line 12 withP1on line 13. - In core
u1, swap the instructionJZon line 3 withJLon line 12. - In core
u1, swap the instructionOUTon line 7 withJZon line 12. - In core
u1, swap the instructionINon line 9 withOUTon line 12.
The finished program
Every tile back in place: the reference solution, which scores exactly par on every benchmark.
u1SC-2 standard
L: IN P0
SUB B
JL K
ADD B
MOV B, A
K: IN P1
JZ L
MOV A, B
OUT P2
MOV A, 0
MOV B, A
H: IN P1
JNZ H- CYCLES
- 800
- at par
- ENERGY
- 1600
- at par
- NODES
- 1
- at par
- INSTRUCTIONS
- 13
- at par
- SWAPS
- 8
- at par