From d04209497b0b440b3f0a73f4512cc1aac1e787ec Mon Sep 17 00:00:00 2001 From: ajet Date: Fri, 19 Dec 2025 08:07:31 -1000 Subject: [PATCH] do day11 part 1 --- 2025/src/day11.clj | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 2025/src/day11.clj diff --git a/2025/src/day11.clj b/2025/src/day11.clj new file mode 100644 index 0000000..b9a1e27 --- /dev/null +++ b/2025/src/day11.clj @@ -0,0 +1,46 @@ +(ns day11 + (:require input-manager + [clojure.string :as str])) + +(def input (->> (if true + (input-manager/get-input 2025 11) + (str/split-lines "svr: aaa bbb +aaa: fft +fft: ccc +bbb: tty +tty: ccc +ccc: ddd eee +ddd: hub +hub: fff +eee: dac +dac: fff +fff: ggg hhh +ggg: out +hhh: out")) + (map (comp (fn [[node & edges]] + [node (into #{} edges)]) + (partial re-seq #"[a-z]{3}"))) + (into {}))) + +;; part 1 +(defn count-paths [start target] + (let [edges (input start)] + (if (contains? edges target) + 1 + (apply + (map #(count-paths % target) edges))))) +(count-paths "you" "out") + +(comment + (defn count-paths-2 [start target visisted] + (let [edges (input start) + visisted' (conj visisted start)] + (cond (contains? edges target) 1 + (contains? visisted start) 0 + :else + (apply + (map #(count-paths-2 % target visisted') edges))))) + + (count-paths-2 "dac" "out" #{}) + (count-paths-2 "fft" "dac" #{}) + (+ (* (count-paths "svr" "dac") (count-paths "dac" "fft") (count-paths "fft" "out")) + (* (count-paths "svr" "fft") (count-paths "fft" "dac") (count-paths "dac" "out")))) +