aoc2021/rkt/01.2.rkt
2021-12-02 18:21:23 +07:00

18 lines
443 B
Racket

#lang racket
(with-input-from-file "../input/01"
(lambda ()
(for/fold ([cnt 0]
[last null]
#:result cnt)
([line (in-lines)])
(let ([num (string->number line)])
(if (< (length last) 3)
(values cnt (append last (list num)))
(values
(if (> num (car last))
(+ cnt 1)
cnt)
(append (cdr last) (list num))))))))