B50AVERAGER
The task
P0 reads a slow triangle wave with a fast square ripple on top. P2 ticks every 20 cycles,
half the ripple's period, so two samples in a row catch one high and one low.
On each tick, put out on P1 the average of the newest sample and the one before.
The board
- Sources
- V1 1 V square at 250 Hz, V2 1.5 V triangle at 12.5 Hz, and V3 2 V
- Resistors
- R1 1 kΩ
- Capacitors
- C1 1 µF
- Probes
- CH1 and CH2
Key idea
XCH swaps A and B, so B can keep the newest sample while A gets the one before.
Hints
Each hint goes a step further than the one before. Open them one at a time.
Hint 1Show
A register holds no more than 127, and two samples can add up to more. Halve each one first.
Hint 2Show
The ripple's high and low cancel in the average, and the triangle is left.
Solution
Reveal the Full SolutionThe complete program for AVERAGER. 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.
The mean of two samples cancels the ripple.
u1SC-2 standard
IN P2
IN P0
DIV 2
XCH
ADD B
OUT P1- CYCLES
- 235
- at par
- ENERGY
- 470
- at par
- NODES
- 1
- at par
- INSTRUCTIONS
- 6
- at par