S41SECOND THOUGHTS
The task
A trigger that takes its time, with every piece out of place.
P0 reads a sine that swings from 10 to 90 percent of the supply.
Turn P1 full on once P0 reaches 70 percent, and off once it falls to 30.
The board
- Sources
- V1 2.5 V and V2 2 V sine at 50 Hz
- Resistors
- R1 1 kΩ
- Capacitors
- C1 1 µF
- Probes
- CH1 and CH2
Key idea
Par is 7 swaps. Core u1 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
Wait in one loop until the input reaches 70, and in another until it falls to 30.
Hint 2Show
JL loops while the input is still under 70, and JG while it is still over 30.
Hint 3Show
Between the two, the output keeps whatever it was last set to.
Solution
Reveal the Full SolutionThe complete program for SECOND THOUGHTS. 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: SUB P0
IN H
IN P1
MOV A, P1
OUT L
H: JL A
SUB 30
JG P0
MOV 70, 0
OUT 1007 swaps back
Make these swaps in order. Lines are numbered from 1 in each core.
- In core
u1, swap the operandP1on line 3 withLon line 5. - In core
u1, swap the operandP1on line 4 with100on line 10. - In core
u1, swap the operandHon line 2 with70on line 9. - In core
u1, swap the operandAon line 6 withP0on line 8. - In core
u1, swap the operandAon line 8 withHon line 9. - In core
u1, swap the instructionSUBon line 1 withINon line 2. - In core
u1, swap the instructionINon line 3 withJLon line 6.
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 70
JL L
MOV A, 100
OUT P1
H: IN P0
SUB 30
JG H
MOV A, 0
OUT P1- CYCLES
- 400
- at par
- ENERGY
- 800
- at par
- NODES
- 1
- at par
- INSTRUCTIONS
- 10
- at par
- SWAPS
- 7
- at par