blob: 90a6358877199232a100e1fb319550689fae82a1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
; add the first three items
(func first-three (inp)
(apply + (list (first inp) (first (rest inp)) (first (rest (rest inp))))))
; return 1 if next three greater than first three
(func is-increasing (inp)
(if (< (first-three inp) (first-three (rest inp)))
1
0))
; this works, but i don't like redefining variables
; also this is slow, maybe there needs to be slices
(func iter-list (inp)
(def acc 0)
(def prev inp)
(for-count (- (list-length inp) 3)
(redef acc (+ acc (is-increasing prev)))
(redef prev (rest prev)))
acc)
(def lines
(map string->int
(map strip
(read-lines "input.txt"))))
(print (->string (iter-list lines)))
|