23 lines
536 B
Racket
23 lines
536 B
Racket
#lang curly-fn racket
|
|
|
|
(require "scripts/aoc.rkt")
|
|
|
|
;; solution for day 1
|
|
|
|
(define (part1 input)
|
|
(apply max (map #{apply + %} input)))
|
|
|
|
(define (part2 input)
|
|
(apply + (~> (map #{apply + %} input) (sort >) (take 3))))
|
|
|
|
(define (parse fname)
|
|
(define elves (string-split (file->string fname) "\n\n"))
|
|
(for/list ([elf (in-list elves)])
|
|
(map string->number (string-split elf "\n"))))
|
|
|
|
(module+ main
|
|
(define input (parse "inputs/1"))
|
|
(answer 1 1 (time (part1 input)))
|
|
(answer 1 2 (time (part2 input)))
|
|
(displayln "meow"))
|