diff options
Diffstat (limited to 'day1/part1.clj')
-rw-r--r-- | day1/part1.clj | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/day1/part1.clj b/day1/part1.clj new file mode 100644 index 0000000..3d6a0f9 --- /dev/null +++ b/day1/part1.clj @@ -0,0 +1,22 @@ +; Day 1, part 1 +; Read a list of numbers from stdin, separated by newlines. +; Count occurances of the current number being greater than +; 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) + ) + ) + ) + |