From bcef26b1e13d873e934d6a1b0975c9b515089a88 Mon Sep 17 00:00:00 2001 From: Luke Hubmayer-Werner Date: Thu, 1 Dec 2022 20:49:20 +1030 Subject: [PATCH] 2022 Day 1 Clojure --- 2022/day1.clj | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 2022/day1.clj diff --git a/2022/day1.clj b/2022/day1.clj new file mode 100644 index 0000000..4b764d2 --- /dev/null +++ b/2022/day1.clj @@ -0,0 +1,7 @@ +(require '[clojure.string :as str]) +(def filename "day1-input") +(def elves-rations (map #(map read-string %) (map str/split-lines (str/split (slurp filename) #"\n\n")))) +(def elves-totals (map #(reduce + %) elves-rations)) +(def sorted-totals (sort elves-totals)) +(println (last sorted-totals)) ; Part 1 +(println (reduce + (take-last 3 sorted-totals))) ; Part 2 \ No newline at end of file