--- /dev/null
+(defn part1pred [lst]
+ (or (and (>= (nth lst 0) (nth lst 2))
+ (<= (nth lst 1) (nth lst 3)))
+ (and (>= (nth lst 2) (nth lst 0))
+ (<= (nth lst 3) (nth lst 1)))))
+
+(defn part2pred [lst]
+ (or (and (>= (nth lst 0) (nth lst 2)) (<= (nth lst 0) (nth lst 3)))
+ (and (>= (nth lst 1) (nth lst 2)) (<= (nth lst 1) (nth lst 3)))
+ (and (>= (nth lst 2) (nth lst 0)) (<= (nth lst 2) (nth lst 1)))
+ (and (>= (nth lst 3) (nth lst 0)) (<= (nth lst 3) (nth lst 1)))))
+
+(def count-filtered (comp println count filter))
+
+(def elf-pairs
+ (->> (slurp "input")
+ (#(clojure.string/split % #"[^\d]"))
+ (map read-string)
+ (partition 4)))
+
+(count-filtered part1pred elf-pairs)
+(count-filtered part2pred elf-pairs)
+
+++ /dev/null
-(->> (slurp "input")
- (#(clojure.string/split % #"[^0-9]"))
- (map read-string)
- (partition 4)
- (map
- #(or (and (>= (first %) (nth % 2))
- (<= (second %) (nth % 3)))
- (and (>= (nth % 2) (first %))
- (<= (nth % 3) (second %)))))
- (filter true?)
- count
- println)
+++ /dev/null
-(->> (slurp "input")
- (#(clojure.string/split % #"[^0-9]"))
- (map read-string)
- (partition 4)
- (map
- #(or (and (>= (first %) (nth % 2)) (<= (first %) (nth % 3)))
- (and (>= (second %) (nth % 2)) (<= (second %) (nth % 3)))
- (and (>= (nth % 2) (first %)) (<= (nth % 2) (second %)))
- (and (>= (nth % 3) (first %)) (<= (nth % 3) (second %)))))
- (filter true?)
- count
- println)