aboutsummaryrefslogtreecommitdiff
path: root/aoc2021/day-01/day-01.rkt
blob: 48ef1583e7a039ec03a80f779bb07fbede9082e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#lang racket
(require advent-of-code
         threading)

;; part 1
(define sensor-data
  (~> (open-aoc-input (find-session) 2021 1 #:cache (string->path "./cache"))
      (port->list read _)))

(define (count-increases data offset)
  (for/sum ([x (in-list data)]
            [y (in-list (drop data offset))]
            #:when (< x y))
    1))

(~a "Part 1: " (count-increases sensor-data 1))

;; part 2

(~a "Part 2: " (count-increases sensor-data 3))