aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClyne Sullivan <clyne@bitgloo.com>2022-12-04 07:34:02 -0500
committerClyne Sullivan <clyne@bitgloo.com>2022-12-04 07:34:02 -0500
commit6b9ec331ef8c35e19c4ccced554a62157bebed3f (patch)
tree647df6682feabad6f693880dcbcce0e7383612dd
parentf0702f04833ffc640ec0299f60f2251b5e0690a0 (diff)
add day4
-rw-r--r--day4/part1.clj12
-rw-r--r--day4/part2.clj12
2 files changed, 24 insertions, 0 deletions
diff --git a/day4/part1.clj b/day4/part1.clj
new file mode 100644
index 0000000..72efa35
--- /dev/null
+++ b/day4/part1.clj
@@ -0,0 +1,12 @@
+(->> (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)
diff --git a/day4/part2.clj b/day4/part2.clj
new file mode 100644
index 0000000..d5929d6
--- /dev/null
+++ b/day4/part2.clj
@@ -0,0 +1,12 @@
+(->> (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)