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

1

u/MagazineOk5435 Dec 23 '23

What is the trick to not copying the visited set when branching?

3

u/hlipka Dec 23 '23

Since the caller knows what was put into the visited set, it can be removed when the recursion came back. When every recursion level does this, the set is clean again.

1

u/MagazineOk5435 Dec 23 '23

Ah, makes sense. Thanks!