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.
Edit: wait I just realized CenturyLink screws with my DNS requests to man-in-the-middle my cert with some Mcafee safe site crap. Changing dns manually to 1.1.1.1 (cloud flare) fixed it. WTF
(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)
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.
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?
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.
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?
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)?
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 :)
13
u/pwnsforyou Dec 08 '23
Suggestion : Add a bit of color for start and end nodes.
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)
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!
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?
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/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)?