diff options
Diffstat (limited to 'day01.clj')
-rw-r--r-- | day01.clj | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/day01.clj b/day01.clj new file mode 100644 index 0000000..c9751f3 --- /dev/null +++ b/day01.clj @@ -0,0 +1,22 @@ +(ns org.vuxu.aoc2021.day01 + (:require [clojure.string :as str])) + +(def data + (->> (slurp "day01") + (str/split-lines) + (map parse-long))) + +(def part1 + (->> data + (partition 2 1) + (filter (partial apply <)) + count)) + +part1 ;; => 1688 + +(def part2 + (->> (map vector data (drop 3 data)) ; a+b+c < b+c+d <==> a < d + (filter (partial apply <)) + count)) + +part2 ;; => 1728 |