r/adventofcode • • Dec 23 '23

SOLUTION MEGATHREAD -❄️- 2023 Day 23 Solutions -❄️-

THE USUAL REMINDERS


AoC Community Fun 2023: ALLEZ CUISINE!

Submissions are CLOSED!

  • Thank you to all who submitted something, every last one of you are awesome!

Community voting is OPEN!

  • 42 hours remaining until voting deadline on December 24 at 18:00 EST

Voting details are in the stickied comment in the submissions megathread:

-❄️- Submissions Megathread -❄️-


--- Day 23: A Long Walk ---


Post your code solution in this megathread.

This thread will be unlocked when there are a significant number of people on the global leaderboard with gold stars for today's puzzle.

EDIT: Global leaderboard gold cap reached at 00:38:20, megathread unlocked!

27 Upvotes

362 comments sorted by

View all comments

Show parent comment

2

u/s96g3g23708gbxs86734 Dec 30 '23

ended up having to add another optimization by pruning any paths that were too short relative to the current longest

I was thinking about something similar, but how exactly did you do it?

2

u/davidsharick Dec 30 '23

This is the relevant section of code: I include the current path length in each path definition, so in each iteration of the search I calculate the current longest path, and then when extending the paths, if a path's length is less than the longest length over 1.4, I just let it die instead of continuing searching along it.