aboutsummaryrefslogtreecommitdiff
path: root/2021/day1/01a.rkt
blob: 5f3ea26faaead9f490b0b175e37d0d78e7aeba6b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#lang racket
(require threading)

(define input (file->lines "input"))

(define (map-differing-lengths f . arrs)
  (define minLength (apply min (map length arrs)))
  (define newLists (map (lambda (x) (take x minLength)) arrs))
  (apply map (cons f newLists)))

(define (diff-pairs xs)
  (map-differing-lengths - (cdr xs) xs))

(~>> input
    (map string->number)
    (diff-pairs)
    (filter positive?)
    (length _))