2021/src/01.rkt

25 lines
542 B
Racket
Raw Normal View History

2021-12-01 05:41:36 +00:00
#lang racket
(require "../lib.rkt")
(define input (map string->number (problem-input 1)))
(define (deltas depths)
(for/list ([depth-prev depths]
[depth-next (rest depths)])
(- depth-next depth-prev)))
(define window-sums
(for/list ([depth-prev input]
[depth-curr (rest input)]
[depth-next (rest (rest input))])
(+ depth-prev depth-curr depth-next)))
(define part1
(count positive? (deltas input)))
(define part2
(count positive? (deltas window-sums)))
(show-solution part1 part2)