From ac2ca562e97b6dde65f8cce938101e6bb43b4236 Mon Sep 17 00:00:00 2001 From: Joseph Ferano Date: Sat, 27 Dec 2025 20:52:59 +0700 Subject: [PATCH] Day 7 p1 --- 2025.clj | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/2025.clj b/2025.clj index 2c4a332..8700c8f 100644 --- a/2025.clj +++ b/2025.clj @@ -348,3 +348,61 @@ L82") (day6-p2 day6-input-test) ;; => 3263827 (day6-p2 (get-input 6)) ;; => 11136895955912 :-) + +;; _____ ______ +;; | __ \ |____ | +;; | | | | __ _ _ _ / / +;; | | | |/ _` | | | | / / +;; | |__| | (_| | |_| | / / +;; |_____/ \__,_|\__, | /_/ +;; __/ | +;; |___/ + + + +(def day7-input-test + ".......S....... +............... +.......^....... +............... +......^.^...... +............... +.....^.^.^..... +............... +....^.^...^.... +............... +...^.^...^.^... +............... +..^...^.....^.. +............... +.^.^.^.^.^...^. +...............") + +(defn day7-p1 [input] + (let [lanes (->> (str/split-lines input) + (mapv vec) + (apply mapv vector)) + length (count (first lanes))] + (loop [active-lanes (set (keep-indexed #(when (= (first %2) \S) %1) lanes)) + idx 2 ;; The splitters start on row 3 + count 0] + (if (= idx length) + count + (let [[new-lanes added-count] + (reduce (fn [[ls c] lane] + (if (not= \^ (get-in lanes [lane idx])) + [ls c] + [(conj (disj ls lane) (dec lane) (inc lane)) (inc c)])) + [active-lanes 0] + active-lanes)] + (recur new-lanes (inc idx) (+ count added-count))))))) + +(defn day7-p2 [input] + ()) + +(comment + (day7-p1 day7-input-test) + (day7-p1 (get-input 7)) + (day7-p2 day7-input-test) + (day7-p2 (get-input 7)) + :-)