diff --git a/2025/src/day09.clj b/2025/src/day09.clj index e559a03..3a31edf 100644 --- a/2025/src/day09.clj +++ b/2025/src/day09.clj @@ -3,19 +3,16 @@ (def input (->> (input-manager/get-input 2025 9) (mapv #(mapv parse-long (re-seq #"\d+" %))))) - (defn area [[ax ay] [bx by]] (* (inc (abs (- ax bx))) (inc (abs (- ay by))))) -(def largest-squares - (->> (for [a input - b input - :when (not= a b)] - #{a b}) - distinct - (map vec) - (sort-by #(apply area %)))) - +(def largest-squares (->> (for [a input + b input + :when (not= a b)] + #{a b}) + distinct + (map vec) + (sort-by #(apply area %)))) ;; part 1 (->> largest-squares last @@ -27,7 +24,6 @@ [[ax ay] [bx by] [cx cy]] (normalize (- (* (- by ay) (- cx bx)) (* (- bx ax) (- cy by))))) - (defn intersect? "Lines AB and CD intersect if points A and B falls on different sides of CD and if C and D fall on different sides of AB" @@ -37,9 +33,9 @@ o3 (orientation c d a) o4 (orientation c d b)] (and (not= o1 o2) (not= o3 o4)))) +(def line-segments (map vector input (conj (vec (rest input)) (first input)))) ;; part 2 -(def line-segments (map vector input (conj (vec (rest input)) (first input)))) (->> largest-squares (filter (fn [[a b]] (let [segments (filter (fn [[seg-a seg-b]] (and (not= a seg-a)