aoc2022/1.rkt

23 lines
536 B
Racket
Raw Normal View History

2022-12-01 05:11:06 +00:00
#lang curly-fn racket
(require "scripts/aoc.rkt")
;; solution for day 1
(define (part1 input)
(apply max (map #{apply + %} input)))
(define (part2 input)
2022-12-01 05:31:48 +00:00
(apply + (~> (map #{apply + %} input) (sort >) (take 3))))
2022-12-01 05:11:06 +00:00
(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"))