From 945a0a01e00d1098c234690e40095414cd8d2256 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Mon, 6 Dec 2021 18:28:40 -0500 Subject: [PATCH] day1: revisit, simplify --- day1/part1.clj | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/day1/part1.clj b/day1/part1.clj index 3d6a0f9..3316424 100644 --- a/day1/part1.clj +++ b/day1/part1.clj @@ -4,19 +4,14 @@ ; the previous. ; -(loop [inc-count 0 - prev (Integer/parseInt (read-line)) - ] - (let [input (read-line)] - (if (not (empty? input)) - (let [depth (Integer/parseInt input)] - (recur - (if (> depth prev) (inc inc-count) inc-count) - depth - ) - ) - (println inc-count) - ) - ) - ) +(->> (slurp "./in") + (clojure.string/split-lines) + (map read-string) + (reduce + #(update [%2 (second %1)] 1 (partial + (if (> %2 (first %1)) 1 0))) + [999999 0] + ) + (second) + (println) + )