aboutsummaryrefslogtreecommitdiffstats
path: root/day1/part1.clj
blob: 3d6a0f9ba5780dcbdc430de57428969044308a46 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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)
      )
    )
  )