Expand description
§Pulse Propagation
Similar to Day 8
the input has a very specific structure. The flip-flips form 4 rows
of 12 columns, following by 2 conjunctions (in square brackets):
/ aa ab ac ad ae af ag ah ai aj aj al [ax] [ay] \
/ ba bb bc bd be bf bg bh bi bj bj bl [bx] [by] \
() - () [zz] -> [rx]
\ ca cb dc cd ce cf cg ch ci cj cj cl [cx] [cy] /
\ da db dc dd de df dg dh di dj dj dl [dx] [dy] /
The penultimate conjuction in each row, for example ax
both takes input and delivers output
to the flips flops. This follows a pattern, for example using v
to indicate input from the
conjunction and v
to indicate output:
v v v v
aa ab ac ad ae af ag ah ai aj aj al
v v v v v v v v v
The flip flops form a binary counter. When the counter reaches a specific value the conjunction
will pulse low and reset the counter to zero. When all 4 counters hit their limit at the
same time then a low pulse will be sent to rx
. The answer is the
LCM of the 4 limit values.
For my input the numbers were co-prime so the LCM simplified to a product.
For part one, as long as all numbers are greater than 1000, then the counting pulses follow a predictable pattern that we can calculate with some bitwise logic.
Functions§
- Use bitwise logic to count pulses.
- Assume all numbers are prime (or co-prime) so that the LCM is equal to the product.
Type Aliases§
- Input 🔒