B54PEAK
The task
A peak meter jumps up with its input and sinks back slowly. P0 reads a sine wave.
On each tick of P2, lower the held level by 3 percent, then raise it to the reading
if the reading is higher. Put the held level out on P1.
The board
- Sources
- V1 2 V sine at 25 Hz and V2 2.5 V
- Resistors
- R1 1 kΩ
- Capacitors
- C1 1 µF
- Probes
- CH1 and CH2
Key idea
B holds the level between ticks.
Hints
Each hint goes a step further than the one before. Open them one at a time.
Hint 1Show
Subtract 3 from the held level first, then compare it with the new reading.
Hint 2Show
Keep whichever is higher, store it in B, and write it out.
Solution
Reveal the Full SolutionThe complete program for PEAK. 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.
Jump up with the input, sink 3 percent a tick.
u1SC-2 standard
IN P2
MOV A, B
SUB 3
MOV B, A
IN P0
SUB B
JL K
ADD B
MOV B, A
K: MOV A, B
OUT P1- CYCLES
- 572
- at par
- ENERGY
- 1144
- at par
- NODES
- 1
- at par
- INSTRUCTIONS
- 11
- at par