golf
This commit is contained in:
parent
055a37a089
commit
c47c11a973
@ -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
|
||||
(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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user