adventofcode 2023-12-20

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

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!

πŸ‘ 1
πŸ‘πŸ» 1
😍 1

Better version, with colors. red - flip-flop, blue - conjunction. Made with https://graphviz.org/.

πŸ”₯ 2

had some time to play with a diagram

πŸ‘ 2
πŸ’ͺ 1

@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!

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.

πŸ‘ 1
πŸ‘πŸ» 1

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

my also are primes

Good and very challenging task! Finally got some profit of my custom graph visualisator πŸ˜„ https://github.com/Ivana-/star-dance

πŸ”₯ 1

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.