B96PATTERN
The task
P0 reads a signal on CH1. Sample it on each tick of P2; a reading DIV 33 is the bit.
Light the LED on P1 for one tick whenever the last four samples, oldest first, were 1, 0, 1, 1.
Overlapping matches count.
The board
- Sources
- V1 1 V square at 250 Hz, V2 0.5 V square at 125 Hz, V3 0.25 V square at 62.5 Hz, and V4 1 V
- Resistors
- R1 330 Ω
- LEDs
- D1 red
- Probes
- CH1 and CH2
Key idea
Keep the last four samples as bits in B: double it, add the new bit, and trim with MOD 16.
Hints
Each hint goes a step further than the one before. Open them one at a time.
Hint 1Show
Read as a binary number, 1, 0, 1, 1 is 11.
Hint 2Show
B minus 11 is zero on a match; write 1 then and 0 otherwise.
Solution
Reveal the Full SolutionThe complete program for PATTERN. 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.
A four bit shift register compared with 11.
u1SC-2 standard
IN P2
IN P0
DIV 33
ADD B
ADD B
MOD 16
MOV B, A
SUB 11
JZ H
MOV A, 0
JMP O
H: MOV A, 1
O: OUT P1- CYCLES
- 1177
- at par
- ENERGY
- 2354
- at par
- NODES
- 1
- at par
- INSTRUCTIONS
- 13
- at par