(or (and (>= r2l r1l) (<= r2h r1h))
(and (>= r1l r2l) (<= r1h r2h)))))
+(defn range-overlaps [r1 r2]
+ (let [[r1l r1h] r1
+ [r2l r2h] r2]
+ (or (and (>= r1h r2l) (<= r1l r2h))
+ (and (>= r2h r1l) (<= r2l r1h)))))
+
(comment
(parse-range "2-4")
(parse-pair "2-4,6-8")
(range-contains (unpack (parse-pair "2-8,3-7")))
(range-contains (unpack (parse-pair "5-7,7-9")))
(range-contains (unpack (parse-pair "6-6,4-6")))
+ (range-overlaps (unpack (parse-pair "2-4,6-8")))
(part1 ["2-4,6-8"
"2-3,4-5"
"5-7,7-9"
"2-8,3-7"
"6-6,4-6"
"2-6,4-8"])
- )
-
+ (part2 ["2-4,6-8"
+ "2-3,4-5"
+ "5-7,7-9"
+ "2-8,3-7"
+ "6-6,4-6"
+ "2-6,4-8"]))
(defn part1 [lines]
(->> lines
(#)))
(defn part2 [lines]
- )
+ (->> lines
+ (c.map parse-pair)
+ (c.filter #(range-overlaps (unpack $1)))
+ (#)))
(comment
(part1 (c.lines "input/day04.txt"))