adventofcode

Maravedis 2024-12-23T06:02:25.868239Z

Day 23 - Solutions

Maravedis 2024-12-23T06:03:04.933639Z

This was so easy. I'm fully expecting to get kicked in the teeth tomorrow.

roklenarcic 2024-12-23T06:08:30.974509Z

I assumed that people just brute forced it, a lot of people were faster than me.

Maravedis 2024-12-23T06:09:22.219089Z

Looking at the solution thread on reddit, yeah, that seems to be the case.

AC 2024-12-23T06:09:28.925429Z

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.

roklenarcic 2024-12-23T06:10:15.614059Z

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.

Maravedis 2024-12-23T06:10:22.830679Z

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.

roklenarcic 2024-12-23T06:11:17.650519Z

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

1
Maravedis 2024-12-23T06:12:04.145099Z

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

roklenarcic 2024-12-23T06:13:17.554909Z

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

bhauman 2024-12-24T15:25:42.531949Z

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

👍 1
erdos 2024-12-23T09:11:29.291789Z

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.

Aleks 2024-12-23T11:06:51.527349Z

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

jvuillermet 2024-12-23T12:32:33.443289Z

thanks @zelark TIL max-key .. very useful

tildedave 2024-12-23T14:46:57.041169Z

similar direct implementation of bron-kerbosch to @zelark; https://github.com/tildedave/advent-of-code/blob/main/src/advent2024/day23.clj

roklenarcic 2024-12-23T14:54:02.161589Z

Today I got my best rank so far, #554 globally

4
Felipe 2024-12-23T23:59:11.417899Z

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

Maravedis 2024-12-23T14:42:43.826679Z

If you look at the graph and the times, 2024 is shaping up to be the easiest year ever: https://aoc.xhyrom.dev/

tildedave 2024-12-23T14:54:59.121249Z

haven't had a 3d puzzle yet, so bracing for tomorrow

roklenarcic 2024-12-23T15:04:22.259269Z

except for day 21 they were all very easy

Maravedis 2024-12-23T15:06:34.548219Z

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.

Maravedis 2024-12-23T15:07:16.567129Z

Or maybe AoC is trying to be more workers friendly, no more "slave away at the problem for 8h" puzzles.

tildedave 2024-12-23T15:07:54.729129Z

one of my coworkers made it to day 15 this year, they bailed earlier every other year. has to be a positive in that.

roklenarcic 2024-12-23T15:16:44.640709Z

These averages are what? Average of top 100 of leaderboard?

roklenarcic 2024-12-23T15:17:26.947229Z

with LLMs these are actually quite useless as far as comparative data goes

Maravedis 2024-12-23T15:19:25.975319Z

Good point, actually.

roklenarcic 2024-12-23T15:19:48.632869Z

All the green days are LLM solves, that’s why times are sub 5min

roklenarcic 2024-12-23T15:20:36.297019Z

I am faster than the average person and I don’t comve even close to these listed average times

Mat 2024-12-24T02:16:57.193799Z

advent of llm