Day 23 - Solutions
This was so easy. I'm fully expecting to get kicked in the teeth tomorrow.
I assumed that people just brute forced it, a lot of people were faster than me.
Looking at the solution thread on reddit, yeah, that seems to be the case.
there are probably smarter ways of doing part1, but mine ran in 8.5sec and that was good enough for me. part2 was similar to part1, but had fewer combinations to churn through. it finished in ~170ms.
And by that I mean, I assumed a lot of people just reused code from part1 in some way. I bruteforced part 1 but I made part2 from scratch because I knew exactly which ubergraph alg to use, still wasn’t faster than erdos. So it was doable without using the correct graph algo.
200ms part1, 40ms part2. I can probably find ways to go faster and make the code shorter, but tbh, today is more of a "parse the input" problem than anything else.
(ns aoc2024.aoc23
(:require [clojure.math.combinatorics :as comb]
[clojure.string :as str]
[ubergraph.alg :as alg]
[ubergraph.core :as u]))
(def input (slurp "/Users/roklenarcic/aoc/aoc24/aoc23.txt"))
(defn parse-input [in] (->> (str/split-lines in) (mapv #(str/split % #"-"))))
(defn cliques [in] (alg/maximal-cliques (apply u/graph (parse-input in))))
(defn interesting-set? [c] (some #(str/starts-with? % "t") c))
(defn p1 [in]
(->> (for [c (cliques in)
triplet (comb/combinations c 3)
:when (interesting-set? triplet)]
triplet)
set count))
(defn p2 [in]
(->> (cliques in)
(apply max-key count)
(sort)
(interpose \,)
(apply str)))
You two are just too fast for me. I deluded myself in thinking I could eventually speed up, but you take a third of the time ><
(time (p1 input))
"Elapsed time: 135.263541 msecs"
=> 1366
(time (p2 input))
"Elapsed time: 90.047042 msecs"
=> "bs,cf,cn,gb,gk,jf,mp,qk,qo,st,ti,uc,xw"Yeah I did 9 hours of holiday driving yesterday. So here’s my solution: https://github.com/bhauman/adv2024/blob/main/src/adv2024/day23/sol.clj Recursion and memoization on part 1, I can probably retrofit my part 2 solution to part 1 60ms part 1 500ms part 2
my day 23 https://github.com/neeasade/aoc-2024?tab=readme-ov-file#day-23-lan-party - happy that https://github.com/clojure/math.combinatorics exists
https://github.com/erdos/advent-of-code/blob/master/2024/day23.clj Runtimes are 0.06s and 1.9s Went with a hand-rolled clique finding algo, although I should start using ubergraph by now.
Part 1 — 50ms, Part 2 — 22ms I implemented Bron-Kerbosch algorithm with a pivot vertex for efficiency. Solution https://github.com/zelark/AoC/blob/master/src/zelark/aoc_2024/day_23.clj Algo https://github.com/zelark/AoC/blob/996dcb28a1b3e961195a09f08e020bba7f6be277/src/zelark/aoc/graph.clj#L55
thanks @zelark TIL max-key .. very useful
similar direct implementation of bron-kerbosch to @zelark; https://github.com/tildedave/advent-of-code/blob/main/src/advent2024/day23.clj
Today I got my best rank so far, #554 globally
had to google the maximal clique algorithm for part 2, but was smooth sailing after that. was scared because I forgot to join using interposing the commas and got wrong answer at first
https://gitlab.com/maximoburrito/advent2024/-/blob/main/src/day23/main.clj
If you look at the graph and the times, 2024 is shaping up to be the easiest year ever: https://aoc.xhyrom.dev/
haven't had a 3d puzzle yet, so bracing for tomorrow
except for day 21 they were all very easy
A couple of part 2s tripped me up, but it was more a me-problem. But yeah, tomorrow has the potential to be very hard.
Or maybe AoC is trying to be more workers friendly, no more "slave away at the problem for 8h" puzzles.
one of my coworkers made it to day 15 this year, they bailed earlier every other year. has to be a positive in that.
These averages are what? Average of top 100 of leaderboard?
with LLMs these are actually quite useless as far as comparative data goes
Good point, actually.
All the green days are LLM solves, that’s why times are sub 5min
I am faster than the average person and I don’t comve even close to these listed average times
advent of llm