Fork me on GitHub
#adventofcode
<
2023-12-20
>
alekszelark13:12:49

Day 20 — Solutions 🤪

alekszelark13:12:54

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 :face_holding_back_tears:

borkdude13:12:35

ah another one of those today? yeah those are fun

erdos15:12:43

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

genmeblog15:12:36

This is schema of my machine!

1
👍 1
😍 1
genmeblog15:12:05

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

🔥 2
alekszelark16:12:58

had some time to play with a diagram

👍 2
💪 1
rjray18:12:23

@U067R559Q 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.

genmeblog18:12:00

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.

rjray18:12:46

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!

alekszelark18:12:44

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.

rjray19:12:13

OK, I've finished both parts now 🙂. Later, when I've commented the code, I'll post here.

👍 1
1
wevrem20:12:24

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

wevrem20:12:43

I guess LCM is safe, but my cycles were all prime. Same for others?

alekszelark21:12:49

My numbers are also prime. It is common to AoC, they like prime numbers 🙂 So usually you just need to multiply them all

genmeblog22:12:31

my also are primes

Ivana22:12:54

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

🔥 1
Ivana23:12:39

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.