adventofcode 2024-12-10

Damn, the difficulty is wild. After spending 4h yesterday, 15 minutes today ? I don't get it.

๐Ÿ˜• 1

Here I learned that you can't just recursively call a function defined in a let binding, yet a lone a memoized version of it. I then went on to extract my function, but this would have meant to extract everything, and I was too lazy for that. Surely there can be an alternative... I then found this https://quanttype.net/posts/2020-09-20-local-memoized-recursive-functions.html and learned about letfn. I didnt even go down the memoized path before trying if it would work without, and yeah it does.

Yeah. part 2 was strange. I just had to delete the concept of 'visited' and it just worked

@tsulej, what di dyou use to generate that ?

tried to keep it small but readable this time ๐Ÿ™‚ https://github.com/erdos/advent-of-code/blob/master/2024/day10.clj

1

A simple recursion. Actually did part2 before part1 because of a misread on my part, so it was very easy to just switch back. https://github.com/Maravedis/advent_code/blob/master/src/advent_of_code/2024/10.clj

Same - I solved part2 first. Reduced it to part1 with a distinct and so part 2 was just removing that call... Wheee...

๐Ÿ‘ 3

> A simple recursion. Actually did part2 before part1 because of a misread on my part, so it was very easy to just switch back Exactly what I did ๐Ÿ˜ฎโ€๐Ÿ’จ

Mine: https://github.com/rjray/advent-2024-clojure/blob/master/src/advent_of_code/day10.clj I guess I could say "I did part 2 first, then part 1." But what I would mean, is, "my last bug in part 1 actually yielded the correct answer for part 2, so I knew what to do."

Straight forward solution with recursion, though I think maybe theres an optimization if you keep a cache of locations and how many paths to 9 they lead to

This has been the easiest year pre-day 10 in AoC history IMO

Usually in first 10 days there has been at least one problem you couldnโ€™t just bruteforce with the dumbest solution you could think of that still worked.

I'm grateful, I usually dip out when they get rougher... not as good as some of the super puzzlers here ๐Ÿคฏ

This is definitely way easier than last year.

I enjoyed today's puzzle, especially since I haven't finished cleaning up yesterday's yet. I tried to make this easy to read while still being concise. One thing I don't know if others did was walking backwards - I started with every 9 and said it had a path only to itself, then every 8 and the mapcat of all its neighbor 9's paths, etc. down to 0. I can already think of a nice optimization on top of this, but I'm tired. ๐Ÿ™‚ โ€ข Blog: https://github.com/abyala/advent-2024-clojure/blob/main/docs/day10.md โ€ข Code: https://github.com/abyala/advent-2024-clojure/blob/main/src/advent_2024_clojure/day10.clj

As they say nothing fancy, just bfs, and dfs for the second part. It works pretty fast. https://github.com/zelark/AoC/blob/master/src/zelark/aoc_2024/day_10.clj

barely any difference between part 1 and part 2, only a single distinct

๐Ÿ‘๐Ÿป 1

@roklenarcic readable and really concise awesome

updated gist to factor out some repeated code

graphs problem

reused my grid library for building grid, finding trailheads, and getting neighbors. I iterate breadth-first, filtering out any neighbor that isnโ€™t the next value we need.

(ns aoc.2024.d10
  (:require
   [aoc.file-util :as f]
   [aoc.grid :as grid]))

(def input (f/read-lines "2024/d10.txt"))

(defn paths [g head]
  (reduce (fn [locs target]
            (->> locs
                 (mapcat grid/neighbor-coords-news)
                 (filter #(= target (get g %)))))
          [head]
          (range 1 10)))

(defn solve [input f]
  (let [g (grid/build-grid input #(Character/getNumericValue %))]
    (transduce (map (comp count f (partial paths g))) + (grid/locate g 0))))

(defn part-1 [input] (solve input distinct))

(defn part-2 [input] (solve input identity))

Today was a nicely straightforward tree-seq solution:

๐ŸŽ„ 1
1

a bit messy but works. solved part two before one accidentally. that's a first

Seems to be a common thing.

yeah, was just reading the other comments

Did almost anybody solved part 2 first? ๐Ÿ˜„

Yeah. Lots of memes about it on reddit too ^^

๐Ÿ™‚ 1

A map!

2
โค๏ธ 4
2

Please do not unpin posts with solutions. This is the way to easily access and list all solution threads. We do this every year. (edited: wording) Found the issue... there is a limit, 100 pins in a channel. I'll unpin old threads then.

๐Ÿ‘Œ 1

If someone is really industrious, maybe we could start a canvas for prior year solution threads

In case some people don't know, there is an extension for firefox & chrome with nice representation of the leaderboard, with tons of stat. It's really fun and I encourage you to try it out: https://github.com/jeroenheijmans/advent-of-code-charts Some screenshots for the current leaderboard:

๐Ÿ’ฏ 2

(if you use it, you might need to hit refresh a couple of time for the thing to display. It's kinda inconsistent).

day 8 going live in 5