1
0
Fork 0
This commit is contained in:
Jonathan Chan 2021-11-30 21:41:36 -08:00 committed by Jonathan Chan
parent 47ba8dd3c0
commit b1de3de1b9
2 changed files with 2024 additions and 0 deletions

2000
input/01.txt Normal file

File diff suppressed because it is too large Load Diff

24
src/01.rkt Normal file
View File

@ -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)