adventofcode-2021/01-solution-02.rkt

11 lines
380 B
Racket

#lang racket
(define strings (file->lines "01-input-01.txt"))
(define nums (map string->number strings))
(define num-larger 0)
(for ([first nums]
[second (list-tail nums 1)]
[third (list-tail nums 2)]
[fourth (list-tail nums 3)])
(when (< (+ first second third) (+ second third fourth))
(set! num-larger (add1 num-larger))))
(print num-larger)