From 51b07c45dc9850559f0adbf22ab7ef887d5aae66 Mon Sep 17 00:00:00 2001 From: Adam Jeniski Date: Sat, 28 Dec 2024 14:43:08 -0500 Subject: [PATCH] day23 part 1 --- 2024/src/day23.clj | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 2024/src/day23.clj diff --git a/2024/src/day23.clj b/2024/src/day23.clj new file mode 100644 index 0000000..abee192 --- /dev/null +++ b/2024/src/day23.clj @@ -0,0 +1,44 @@ +(ns day23 + (:require + [clojure.math :as math] + [clojure.math.combinatorics :as combo] + [clojure.string :as s] + [core :as c :refer :all] + [input-manager :as i])) + +(def edges (->> (i/get-input 2024 23) + (map #(c/get-match-groups #"^(.*)-(.*)$" %)) + (map first) + (map (partial into #{})) + set)) + +(def nodes (->> edges + (map seq) + flatten + set)) + +;; part 1 +(def part-1-ans + (future + (->> (combo/combinations edges 2) + (mmap vec) + (map flatten) + (map set) + (filter #(= (count %) 3)) + (map seq) + (filter (partial some #(.startsWith % "t"))) + (filter (fn [[a b _]] (edges #{a b}))) + (filter (fn [[_ b c]] (edges #{b c}))) + (filter (fn [[a _ c]] (edges #{a c}))) + (map set) + set + count))) +(future + (println "processing part 1...") + (println "part 1 answer:" @part-1-ans)) + +(comment + (realized? part-1-ans) + (deref part-1-ans 0 "still processing") + @part-1-ans) +