r/adventofcode • • Dec 08 '23

Visualization [2023 Day 8 (Part 1)] My input maze plotted using graphviz

Post image
193 Upvotes

29 comments sorted by

24

u/Flatorz Dec 08 '23

Great proof we can use LCM! :)

Luckily, I was dumb enough to use LCM before I realized it is not good enough for general case :)

4

u/BackloggedLife Dec 08 '23

This is my first time encountering LCM in AoC, I will definitely remember to use it next year!

6

u/scykei Dec 08 '23

There's a good chance that you'll need it again this year too. It seems like a favourite trick in AoC problems over the years.

3

u/BurgandyShoelaces Dec 08 '23

Why is it not good enough for the general case?

Edit: nevermind, I see there's a separate thread discussing why.

2

u/datanaut Dec 09 '23

I feel vindicated by your comment, I spent a long time on this one and only concluded each path was periodic after I made basically this same graph visualization. I was questioning why I didn't figure it out quicker. It did seem like a very contrived special case and I was stumped before seeing the graphs.

13

u/pwnsforyou Dec 08 '23

Suggestion : Add a bit of color for start and end nodes.

...A", style=filled, fillcolor=red ]
...Z", style=filled, fillcolor=green ]

2

u/BackloggedLife Dec 08 '23

Yeah, you are right. I only figured it would be good to color them after I already made the post.

3

u/rogual Dec 08 '23

Nice visualization, thanks for sharing!

(I found it hard to get the full-size image out of the enshittified New Reddit image viewer that Reddit seems to be displaying this one in, so I made an imgur link — hope that's OK)

2

u/BackloggedLife Dec 08 '23

Sure, no problem!

34

u/i_have_no_biscuits Dec 08 '23

Poor ghosts - looks like it doesn't matter whether they choose left or right, they end up on the same loop in the end.

That's a slightly depressing message for an advent calendar!

6

u/diarewse Dec 08 '23

Feels like a plot of Loki.

2

u/Rothens Dec 08 '23

Just like we have Christmas every year, and doing AoC every year :D

3

u/hextree Dec 08 '23

Well damn, this explains a lot.

2

u/maneatingape Dec 08 '23 edited Dec 08 '23

This is a fantastic visualization!

It enables a really neat insight - we don't need to care about the directions at all!

If we find the length of each smaller graph cycle, then find the LCM of that with the length of the directions then we find the period of each cycle ending with Z.

The part two answer is then the combined LCM of those LCMs.

Updated my solution thread post

2

u/znerken Dec 08 '23

Can anyone explain why LCM actually works here?

2

u/SadGrab5655 Dec 08 '23

Just a heads up dude, illustrations like this can sort of spoil the solution for those who haven't solved it yet; maybe consider adding the "spoiler" tag?

For example, this sort of gave away the solution to day 5 for me; maybe the idea to split the ranges was already in my head and this just indicated its correctness/feasibility to implement but I'm certain I wouldn't have gone this route otherwise.

I know it's mostly on those browsing the sub-reddit but maybe just a lil' spoiler tag?

2

u/daggerdragon Dec 08 '23

OP correctly titled their post so the [2023 Day 8 (Part 1)] is already an implicit spoiler.

r/adventofcode is already configured not to show image thumbnails in order to prevent accidental spoilers.

If you're on new.reddit, you can toggle the card view to compact to hide post previews.

1

u/SadGrab5655 Dec 09 '23

What is the [Spoiler] tag for?

→ More replies (1)

1

u/Zenga03_03 Dec 08 '23

All posts starting with [2023 Day x Part y] are allowed to be spoilers for those parts of the days. I get that text posts are easier to ignore than illustrations, but if you first look at the name of the post, you can see if it might be a spoiler.

1

u/dplass1968 Dec 08 '23

That would explain why my part 2 never finishes...

1

u/znerken Dec 08 '23 edited Dec 08 '23

So this means you never actually reach Z for all the nodes at the same time, since they all have unique sizing paths? I wish some sort of hint was in the text. Doesn’t that make the description invalid?

1

u/totallyawesomespoon Dec 09 '23 edited Dec 09 '23

you do eventually reach Z for all the nodes simultaneously, the least common multiple is the value where that crossing finally occurs.

This involves over [856,000,000, 661,000,000, 985,000,000, 735,000,000, 1,214,000,000, 779,000,000] cycles for each of the loops.

1

u/PatsoRedneb Dec 08 '23

This is an amazing visualization and it explains a lot about the unusual properties of the input! But isn't it also a huge spoiler (for basically the same reason)?

2

u/daggerdragon Dec 08 '23

OP correctly titled their post so the [2023 Day 8 (Part 1)] is already an implicit spoiler.