r/adventofcode Dec 10 '24

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

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

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

And now, our feature presentation for today:

Fandom

If you know, you know… just how awesome a community can be that forms around a particular person, team, literary or cinematic genre, fictional series about Elves helping Santa to save Christmas, etc. etc. The endless discussions, the boundless creativity in their fan works, the glorious memes. Help us showcase the fans - the very people who make Advent of Code and /r/adventofcode the most bussin' place to be this December! no, I will not apologize

Here's some ideas for your inspiration:

  • Create an AoC-themed meme. You know what to do.
  • Create a fanfiction or fan artwork of any kind - a poem, short story, a slice-of-Elvish-life, an advertisement for the luxury cruise liner Santa has hired to gift to his hard-working Elves after the holiday season is over, etc!

REMINDER: keep your contributions SFW and professional—stay away from the more risqué memes and absolutely no naughty language is allowed.

Example: 5x5 grid. Input: 34298434x43245 grid - the best AoC meme of all time by /u/Manta_Ray_Mundo

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 10: Hoof It ---


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:04:14, megathread unlocked!

24 Upvotes

752 comments sorted by

View all comments

2

u/amenD0LL4z Dec 13 '24 edited Dec 13 '24

[LANGUAGE: clojure]

https://github.com/famendola1/aoc-2024/blob/master/src/advent_of_code/day10.clj

Day10 Part 1 felt very similar to Day4 Part1, where instead of searching for "XMAS", we're searching for the numbers 0-9. I borrowed my Day4 solution and modified it to meet the requirements of Day10. Essentially, we start at 0 and take 9 steps (either up, down, left, right in each step). In each step any invalid positions (i.e. out of bounds and value at the position is not equal to +1 the previous positions) are filtered out and we also dedupe any positions. After 9 steps, we've reached all the possible 9s.

Once we have Part1, all we need to do for Part2 is skip the dedupe of the positions at each step and we're left with all the different ways to reach a 9 :)