B83STRETCH
The task
P0 reads pulses of different lengths on CH1. Sample it on each tick of P2.
Light the LED on P1 while a pulse is high, then keep it lit as many ticks again after it falls.
A pulse of 6 ticks lights the LED for 12.
The board
- Sources
- V1 2 V square at 25 Hz and V2 1.2 V square at 62.5 Hz
- Resistors
- R1 330 Ω
- LEDs
- D1 yellow
- Probes
- CH1 and CH2
Key idea
Count the ticks the input reads high in B.
Hints
Each hint goes a step further than the one before. Open them one at a time.
Hint 1Show
After it falls, count B back down to zero, one per tick, with the LED still lit.
Hint 2Show
When the count reaches zero, put the LED out and wait for the next pulse.
Solution
Reveal the Full SolutionThe complete program for STRETCH. Open it only when you want the answer.
The reference program
The game's own solution. It passes every test and scores exactly par on every benchmark.
Count up while high, count down after, lit until zero.
u1SC-2 standard
L: IN P2
IN P0
JZ E
OUT P1
MOV A, B
ADD 1
MOV B, A
JMP L
E: MOV A, B
JZ L
SUB 1
MOV B, A
JNZ L
OUT P1- CYCLES
- 586
- at par
- ENERGY
- 1172
- at par
- NODES
- 1
- at par
- INSTRUCTIONS
- 14
- at par