aboutsummaryrefslogtreecommitdiffstats
path: root/year2021/day1/part2.clj
diff options
context:
space:
mode:
Diffstat (limited to 'year2021/day1/part2.clj')
-rw-r--r--year2021/day1/part2.clj15
1 files changed, 15 insertions, 0 deletions
diff --git a/year2021/day1/part2.clj b/year2021/day1/part2.clj
new file mode 100644
index 0000000..e496c7d
--- /dev/null
+++ b/year2021/day1/part2.clj
@@ -0,0 +1,15 @@
+; Day 1, part 2
+; Read a list of numbers from stdin, separated by newlines.
+; Count occurances of the current sum being greater than
+; the previous, where a sum is that of the current number,
+; the previous number, and the next number.
+;
+
+(let [input (->> (slurp "./in")
+ clojure.string/split-lines
+ (mapv read-string))]
+ (println
+ (count
+ (filter #(< (get input %) (get input (+ % 3)))
+ (range 0 (- (count input) 3))))))
+