2021/src/01.rkt

18 lines
355 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 nth-rest)
2021-12-01 05:41:36 +00:00
(for/list ([depth-prev input]
[depth-next (nth-rest input)])
(- depth-next depth-prev)))
2021-12-01 05:41:36 +00:00
(define part1
(count positive? (deltas cdr)))
2021-12-01 05:41:36 +00:00
(define part2
(count positive? (deltas cdddr)))
2021-12-01 05:41:36 +00:00
(show-solution part1 part2)