Day 01.
This commit is contained in:
parent
47ba8dd3c0
commit
b1de3de1b9
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,24 @@
|
|||
#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)
|
Loading…
Reference in New Issue