Compare commits

...

2 Commits

Author SHA1 Message Date
aae7ad038b simplify 2025-12-08 22:32:23 -10:00
5ca7f15404 golf + comments 2025-12-08 22:29:46 -10:00

View File

@ -33,19 +33,18 @@
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))))
(def line-segments (map vector input (rest input)))
;; part 2
(->> largest-squares
(filter (fn [[a b]]
(let [segments (filter (fn [[seg-a seg-b]] (and (not= a seg-a)
(not= a seg-b)
(not= b seg-a)
(not= b seg-b)))
(let [segments (filter (fn overlapping? [[seg-a seg-b]]
(and (not= a seg-a) (not= a seg-b)
(not= b seg-a) (not= b seg-b))) ;; filter out segments that include points a or b
line-segments)
[[cx cy] [dx dy]] [a b]]
(and (not (some #(intersect? [a b] %) segments))
(not (some #(intersect? [[cx dy] [dx cy]] %) segments))))))
(not (some #(intersect? [[cx dy] [dx cy]] %) segments)))))) ;; check reverse diaganol too
(sort-by (partial apply area))
last
(apply area))