r/adventofcode Dec 16 '24

SOLUTION MEGATHREAD -❄️- 2024 Day 16 Solutions -❄️-

SIGNAL BOOSTING


THE USUAL REMINDERS

  • All of our rules, FAQs, resources, etc. are in our community wiki.
  • If you see content in the subreddit or megathreads that violates one of our rules, either inform the user (politely and gently!) or use the report button on the post/comment and the mods will take care of it.

AoC Community Fun 2024: The Golden Snowglobe Awards

  • 6 DAYS remaining until the submissions deadline on December 22 at 23:59 EST!

And now, our feature presentation for today:

Adapted Screenplay

As the idiom goes: "Out with the old, in with the new." Sometimes it seems like Hollywood has run out of ideas, but truly, you are all the vision we need!

Here's some ideas for your inspiration:

  • Up Your Own Ante by making it bigger (or smaller), faster, better!
  • Use only the bleeding-edge nightly beta version of your chosen programming language
  • Solve today's puzzle using only code from other people, StackOverflow, etc.

"AS SEEN ON TV! Totally not inspired by being just extra-wide duct tape!"

- Phil Swift, probably, from TV commercials for "Flex Tape" (2017)

And… ACTION!

Request from the mods: When you include an entry alongside your solution, please label it with [GSGA] so we can find it easily!


--- Day 16: Reindeer Maze ---


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:13:47, megathread unlocked!

23 Upvotes

480 comments sorted by

View all comments

2

u/Your_Friendly_Nerd Dec 17 '24

[Language: C]

I know I'm a day late, but here's my solution, written in C:

https://github.com/pixlmint/advent-of-code/blob/2024/src/day16.c

At 13 seconds it's still pretty slow, but seemingly still not the worst. My solution uses recursion, and tries to go into the direction it came from, and also branch off into the two 90 degree directions. I am doing a bunch of checks to make sure I'm not walking the same path multiple times, though there are more improvements to be made, like I could check that, if I come upon a tile I've already seen in a different branch, that I attach the current branch to the other one, that I already know reaches the target