Day 20 β Solutions π€ͺ
I solved both parts, but need some times for rest and cleaning up my code. Actually I like it much more than yesterdayβs one. I have good memories about microcircuitry classes in the university π₯Ή
ah another one of those today? yeah those are fun
Yeah, here is my solution https://github.com/zelark/AoC/blob/master/src/zelark/aoc_2023/day_20.clj
I went with ugly global mutable state by just keeping track of the actions in two atoms. It is definitely not nice but helped keep the functions relatively small. https://github.com/erdos/advent-of-code/blob/master/2023/day20.clj
This is schema of my machine!
Better version, with colors. red - flip-flop, blue - conjunction. Made with https://graphviz.org/.
had some time to play with a diagram
@zelark Can you explain how LCM plays into this? I quickly realized I can't just keep pressing the button. I looked at your solution, but it's enough different from my core that I don't fully follow what the values passed to LCM are.
Let me explain. Each of the four conjunctions connected to the last one triggers in some cycle. You need to find them and common cycle.
Ah, I see. I need to identify those 4 and determine their cycle. Now, I just have to figure out how to do that with the code I already have π. Thanks!
@rjray I explained it more here https://www.reddit.com/r/adventofcode/comments/18mz6iy/2023_day_20_part_2_on_how_binary_counter_works/
About my way to find them, I take flip-flops connected right to the broadcast module. There are 4 as I observed. When a counter resets, it also resets an initial flip-flop from a branch (there is a back loop). It means if you find two adjacent states of the flip-flop with the same value (off off) youβll find a loop.
OK, I've finished both parts now π. Later, when I've commented the code, I'll post here.
Well https://github.com/wevre/advent-of-code/blob/master/src/advent_of_code/2023/day_20_pulses.clj was easy enough, but I donβt know if I ever would have figured out what was going on without insight from @zelark
I guess LCM is safe, but my cycles were all prime. Same for others?
My numbers are also prime. It is common to AoC, they like prime numbers π So usually you just need to multiply them all
Here is https://github.com/alexalemi/advent/blob/main/2023/clojure/p20.clj , this one took quite a while.
my also are primes
https://github.com/genmeblog/advent-of-code/blob/master/src/advent_of_code_2023/day20.clj
Good and very challenging task! Finally got some profit of my custom graph visualisator π https://github.com/Ivana-/star-dance
But I think actually to find the cycles is not enough for solving this task imho. You have to prove (or check, like I did) that all the needed pulses occurs on the same step of the pulse propagation during each push. Topology of that 4 subgraphs are similar, but the required (forces high level pulse on all the inputs of pre-last Conjunction module) steps sets inside push are different, thanks God they have non-empty intersection.
https://github.com/rjray/advent-2023-clojure/blob/master/src/advent_of_code/day20.clj Got my code commented. Been a long day at work...