B79INTERLOCK
The task
P0 asks the hoist to go up, P1 asks it to go down. P2 drives up, P3 drives down.
A request is granted only while the other direction is off; it then holds until released.
A request that waited is granted as soon as the other side lets go.
The board
- Sources
- V1 5 V, V2 5 V square at 20 Hz, V3 5 V, and V4 5 V square at 12.5 Hz
- Resistors
- R1 330 Ω and R2 330 Ω
- LEDs
- D1 green and D2 red
- Probes
- CH1, CH2, CH3, and CH4
Key idea
Never drive both: while one output is on, ignore the other request.
Hints
Each hint goes a step further than the one before. Open them one at a time.
Hint 1Show
When nothing is on, check both requests and grant the first you find.
Hint 2Show
Write a loop for each direction that holds until its request drops.
Solution
Reveal the Full SolutionThe complete program for INTERLOCK. 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.
One direction at a time; each holds until released.
u1SC-2 standard
I: IN P0
JNZ U
IN P1
JZ I
OUT P3
DN: IN P1
JNZ DN
OUT P3
JMP I
U: OUT P2
W: IN P0
JNZ W
OUT P2- CYCLES
- 1800
- at par
- ENERGY
- 3600
- at par
- NODES
- 1
- at par
- INSTRUCTIONS
- 13
- at par