adventofcode

Aleks 2023-12-20T13:06:49.395959Z

Day 20 β€” Solutions πŸ€ͺ

Aleks 2023-12-20T13:10:54.437909Z

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 πŸ₯Ή

borkdude 2023-12-20T13:22:35.277709Z

ah another one of those today? yeah those are fun

Aleks 2023-12-20T14:15:39.222489Z

Yeah, here is my solution https://github.com/zelark/AoC/blob/master/src/zelark/aoc_2023/day_20.clj

erdos 2023-12-20T15:13:43.220949Z

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

genmeblog 2023-12-20T15:18:36.897299Z

This is schema of my machine!

πŸ‘ 1
πŸ‘πŸ» 1
😍 1
genmeblog 2023-12-20T15:29:05.775579Z

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

πŸ”₯ 2
Aleks 2023-12-20T16:59:58.868669Z

had some time to play with a diagram

πŸ‘ 2
πŸ’ͺ 1
rjray 2023-12-20T18:04:23.099449Z

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

genmeblog 2023-12-20T18:12:00.522879Z

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.

rjray 2023-12-20T18:28:46.296619Z

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!

Aleks 2023-12-20T18:34:44.992269Z

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.

rjray 2023-12-20T19:35:13.238319Z

OK, I've finished both parts now πŸ™‚. Later, when I've commented the code, I'll post here.

πŸ‘ 1
πŸ‘πŸ» 1
wevrem 2023-12-20T20:28:24.481799Z

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

wevrem 2023-12-20T20:51:43.308849Z

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

Aleks 2023-12-20T21:14:49.659469Z

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

2023-12-20T22:09:29.007579Z

Here is https://github.com/alexalemi/advent/blob/main/2023/clojure/p20.clj , this one took quite a while.

genmeblog 2023-12-20T22:34:31.498019Z

my also are primes

Ivana 2023-12-20T22:59:54.043599Z

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

πŸ”₯ 1
Ivana 2023-12-20T23:36:39.503099Z

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.

rjray 2023-12-21T00:54:38.728769Z

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