B09RECTIFIER
The task
V1 and V2 put a sine wave on P0, swinging 2 volts either side of 2.5 volts.
Fold it: on CH2, output the distance from the middle, doubled, as a PWM duty on P1.
Above the middle and below it, the output rises the same.
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
The middle, 2.5 volts, reads as 50 percent.
Hints
Each hint goes a step further than the one before. Open them one at a time.
Hint 1Show
Subtract 50, then make the result positive: NEG flips the sign of A.
Hint 2Show
Doubling 40 percent from the middle gives 80 percent: 4 volts at the peaks.
Solution
Reveal the Full SolutionThe complete program for RECTIFIER. 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.
u1SC-2 standard
IN P0
SUB 50
JG W
NEG
W: MUL 2
OUT P1- CYCLES
- 400
- at par
- ENERGY
- 800
- at par
- NODES
- 1
- at par
- INSTRUCTIONS
- 6
- at par
Another way: Double first
A second program that also passes, and matches par on every benchmark.
Doubles first, then folds.
u1SC-2 standard
IN P0
SUB 50
MUL 2
JG W
NEG
W: OUT P1- CYCLES
- 400
- at par
- ENERGY
- 800
- at par
- NODES
- 1
- at par
- INSTRUCTIONS
- 6
- at par