Damn, the difficulty is wild. After spending 4h yesterday, 15 minutes today ? I don't get it.
Day 10 - Solutions
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 ?
@qmstuart clojure2d - source code for that: https://github.com/genmeblog/advent-of-code/blob/master/src/advent_of_code_2024/day10.clj#L40-L72
tried to keep it small but readable this time ๐ https://github.com/erdos/advent-of-code/blob/master/2024/day10.clj
https://gitlab.com/maximoburrito/advent2024/-/blob/main/src/day10/main.clj
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...
> 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
https://gist.github.com/RokLenarcic/e8841f84241ccfe1913e3bedd5cde7f6 really simple
barely any difference between part 1 and part 2, only a single distinct
@roklenarcic readable and really concise awesome
updated gist to factor out some repeated code
Another sweet and simple one https://codeberg.org/nathell/aoc2024/src/branch/main/src/aoc2024/day10.clj
graphs problem
https://github.com/genmeblog/advent-of-code/blob/master/src/advent_of_code_2024/day10.clj
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:
https://github.com/bhauman/adv2024/blob/main/src/adv2024/day10/sol.clj
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 ^^
A map!
https://github.com/ghaskins/adventofcode/blob/main/src/aoc/2024/day10.clj
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.
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:
(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