]> code.bitgloo.com Git - clyne/advent-of-code.git/commitdiff
day1: revisit, simplify
authorClyne Sullivan <clyne@bitgloo.com>
Mon, 6 Dec 2021 23:28:40 +0000 (18:28 -0500)
committerClyne Sullivan <clyne@bitgloo.com>
Mon, 6 Dec 2021 23:28:40 +0000 (18:28 -0500)
day1/part1.clj

index 3d6a0f9ba5780dcbdc430de57428969044308a46..3316424b9210cad46a198b330830c0c5ef275ff9 100644 (file)
@@ -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)
+     )