golf + comments
This commit is contained in:
parent
c47c11a973
commit
5ca7f15404
@ -38,14 +38,13 @@
|
|||||||
;; part 2
|
;; part 2
|
||||||
(->> largest-squares
|
(->> largest-squares
|
||||||
(filter (fn [[a b]]
|
(filter (fn [[a b]]
|
||||||
(let [segments (filter (fn [[seg-a seg-b]] (and (not= a seg-a)
|
(let [segments (filter (fn overlapping? [[seg-a seg-b]]
|
||||||
(not= a seg-b)
|
(and (not= a seg-a) (not= a seg-b)
|
||||||
(not= b seg-a)
|
(not= b seg-a) (not= b seg-b))) ;; filter out segments that include points a or b
|
||||||
(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))))))
|
(not (some #(intersect? [[cx dy] [dx cy]] %) segments)))))) ;; check reverse diaganol too
|
||||||
(sort-by (partial apply area))
|
(sort-by (partial apply area))
|
||||||
last
|
last
|
||||||
(apply area))
|
(apply area))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user