adventofcode

Maravedis 2024-12-10T05:23:58.256169Z

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

๐Ÿ˜• 1
2024-12-10T05:32:55.816099Z

Day 10 - Solutions

Felix Dorner 2024-12-15T20:23:28.258849Z

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.

2024-12-11T12:56:18.674349Z

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

2024-12-11T12:57:02.058209Z

@tsulej, what di dyou use to generate that ?

genmeblog 2024-12-11T12:58:43.861169Z

@qmstuart clojure2d - source code for that: https://github.com/genmeblog/advent-of-code/blob/master/src/advent_of_code_2024/day10.clj#L40-L72

๐Ÿ‘ 1
erdos 2024-12-10T05:34:09.657909Z

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

1
Maravedis 2024-12-10T05:35:53.030579Z

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

2024-12-10T05:36:42.708559Z

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

๐Ÿ‘ 3
Sam Ferrell 2024-12-10T06:21:42.539889Z

> 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 ๐Ÿ˜ฎโ€๐Ÿ’จ

rjray 2024-12-10T06:23:13.892749Z

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."

Sam Ferrell 2024-12-10T06:23:45.317939Z

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

roklenarcic 2024-12-10T06:30:37.945359Z

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

roklenarcic 2024-12-10T06:31:13.039809Z

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.

Sam Ferrell 2024-12-10T06:42:34.716099Z

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

Maravedis 2024-12-10T06:44:25.672959Z

This is definitely way easier than last year.

Andrew Byala 2024-12-10T07:20:28.981929Z

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

Aleks 2024-12-10T07:43:49.654449Z

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

roklenarcic 2024-12-10T07:50:38.330979Z

https://gist.github.com/RokLenarcic/e8841f84241ccfe1913e3bedd5cde7f6 really simple

roklenarcic 2024-12-10T07:52:08.647989Z

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

๐Ÿ‘๐Ÿป 1
Aleks 2024-12-10T08:05:46.853849Z

@roklenarcic readable and really concise awesome

roklenarcic 2024-12-10T08:09:03.596089Z

updated gist to factor out some repeated code

djanus 2024-12-10T08:54:42.349689Z

Another sweet and simple one https://codeberg.org/nathell/aoc2024/src/branch/main/src/aoc2024/day10.clj

exitsandman 2024-12-10T09:07:10.563469Z

graphs problem

tschady 2024-12-10T10:50:06.016429Z

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))

bhauman 2024-12-10T13:04:57.941849Z

Today was a nicely straightforward tree-seq solution:

bhauman 2024-12-10T13:06:11.600929Z

๐ŸŽ„ 1
1
Felipe 2024-12-10T13:47:46.170629Z

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

Maravedis 2024-12-10T13:48:46.503359Z

Seems to be a common thing.

Felipe 2024-12-10T13:49:16.050649Z

yeah, was just reading the other comments

vncz 2024-12-10T14:09:55.818269Z

vncz 2024-12-10T14:10:30.255899Z

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

Maravedis 2024-12-10T14:12:04.144879Z

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

๐Ÿ™‚ 1
genmeblog 2024-12-10T19:27:57.827459Z

A map!

2
โค๏ธ 4
2
genmeblog 2024-12-10T09:37:26.843839Z

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
2024-12-11T19:16:28.993029Z

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

Maravedis 2024-12-10T13:14:50.392219Z

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
Maravedis 2024-12-10T13:15:37.462809Z

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

2024-12-10T16:56:29.314749Z

day 8 going live in 5