S19EVERY OTHER
The task
The divider, swapped about. Swap it back.
Toggle the LED on P1 at every rising edge of the square wave on P0.
It blinks at half the rate of the input.
The board
- Sources
- V1 5 V square at 250 Hz
- Resistors
- R1 330 Ω
- LEDs
- D1 green
- Probes
- CH1 and CH2
Key idea
Par is 4 swaps. Core u1 needs 2 instruction swaps and 2 operand swaps. 3 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 for the high with JZ, and after the toggle wait for the low with JNZ.
Hint 2Show
1 minus the LED's last state is its next state. B keeps the state.
Hint 3Show
MOV B, A keeps the new state before OUT sends it.
Solution
Reveal the Full SolutionThe complete program for EVERY OTHER. 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 P0
JNZ L
MOV B, 1
IN P0
MOV B, A
OUT P1
H: SUB A
JZ H4 swaps back
Make these swaps in order. Lines are numbered from 1 in each core.
- In core
u1, swap the operandBon line 3 withAon line 7. - In core
u1, swap the operandP0on line 4 withBon line 7. - In core
u1, swap the instructionJNZon line 2 withJZon line 8. - In core
u1, swap the instructionINon line 4 withSUBon line 7.
The finished program
Every tile back in place: the reference solution, which scores exactly par on every benchmark.
u1SC-2 standard
L: IN P0
JZ L
MOV A, 1
SUB B
MOV B, A
OUT P1
H: IN P0
JNZ H- CYCLES
- 400
- at par
- ENERGY
- 800
- at par
- NODES
- 1
- at par
- INSTRUCTIONS
- 8
- at par
- SWAPS
- 4
- at par