Compare commits

..

No commits in common. "aae7ad038b6625000c5e0b99d4b83a69e554e643" and "c47c11a973fef8b0cf53bd8c60e8b2a6db8ec136" have entirely different histories.

View File

@ -33,18 +33,19 @@
o3 (orientation c d a) o3 (orientation c d a)
o4 (orientation c d b)] o4 (orientation c d b)]
(and (not= o1 o2) (not= o3 o4)))) (and (not= o1 o2) (not= o3 o4))))
(def line-segments (map vector input (rest input))) (def line-segments (map vector input (conj (vec (rest input)) (first input))))
;; part 2 ;; part 2
(->> largest-squares (->> largest-squares
(filter (fn [[a b]] (filter (fn [[a b]]
(let [segments (filter (fn overlapping? [[seg-a seg-b]] (let [segments (filter (fn [[seg-a seg-b]] (and (not= a seg-a)
(and (not= a seg-a) (not= a seg-b) (not= a seg-b)
(not= b seg-a) (not= b seg-b))) ;; filter out segments that include points a or b (not= b seg-a)
(not= b seg-b)))
line-segments) line-segments)
[[cx cy] [dx dy]] [a b]] [[cx cy] [dx dy]] [a b]]
(and (not (some #(intersect? [a b] %) segments)) (and (not (some #(intersect? [a b] %) segments))
(not (some #(intersect? [[cx dy] [dx cy]] %) segments)))))) ;; check reverse diaganol too (not (some #(intersect? [[cx dy] [dx cy]] %) segments))))))
(sort-by (partial apply area)) (sort-by (partial apply area))
last last
(apply area)) (apply area))