aboutsummaryrefslogtreecommitdiffstats
path: root/AoC2022/aocclj/src
diff options
context:
space:
mode:
Diffstat (limited to 'AoC2022/aocclj/src')
-rw-r--r--AoC2022/aocclj/src/aocclj/core.clj8
-rw-r--r--AoC2022/aocclj/src/aocclj/day01.clj18
2 files changed, 26 insertions, 0 deletions
diff --git a/AoC2022/aocclj/src/aocclj/core.clj b/AoC2022/aocclj/src/aocclj/core.clj
new file mode 100644
index 0000000..35a8acb
--- /dev/null
+++ b/AoC2022/aocclj/src/aocclj/core.clj
@@ -0,0 +1,8 @@
+(ns aocclj.core
+ (:gen-class)
+ (:require [clojure.string :as str]))
+
+(defn -main
+ "I don't do a whole lot ... yet."
+ [& args]
+ (println "Hello, World!"))
diff --git a/AoC2022/aocclj/src/aocclj/day01.clj b/AoC2022/aocclj/src/aocclj/day01.clj
new file mode 100644
index 0000000..8fca2e6
--- /dev/null
+++ b/AoC2022/aocclj/src/aocclj/day01.clj
@@ -0,0 +1,18 @@
+(ns aocclj.day01
+ (:require [clojure.string :as str]))
+
+(defn preprocess [input]
+ (transduce
+ (comp
+ (map parse-long)
+ (partition-by nil?)
+ (take-nth 2)
+ (map (partial reduce +)))
+ conj
+ input))
+
+(defn part1 [input]
+ (apply max (preprocess input)))
+
+(defn part2 [input]
+ (->> input preprocess sort (take 3) (apply +)))