Initial commit
This commit is contained in:
commit
f242d2b0df
420 changed files with 62521 additions and 0 deletions
25
2022/day01/day01.rkt
Normal file
25
2022/day01/day01.rkt
Normal file
|
@ -0,0 +1,25 @@
|
|||
#lang racket
|
||||
|
||||
(require threading)
|
||||
|
||||
(define (read-input filename)
|
||||
(for/list ([s (string-split (file->string filename) "\n\n")])
|
||||
(for/list ([n (string-split s "\n")])
|
||||
(string->number n))))
|
||||
|
||||
(define (sum l)
|
||||
(apply + l))
|
||||
|
||||
(define part1
|
||||
(lambda~>> (map sum)
|
||||
(apply max)))
|
||||
|
||||
(define part2
|
||||
(lambda~> (map sum _)
|
||||
(sort _ >)
|
||||
(take _ 3)
|
||||
(apply + _)))
|
||||
|
||||
(define input (read-input "input"))
|
||||
(displayln (part1 input))
|
||||
(displayln (part2 input))
|
Loading…
Add table
Add a link
Reference in a new issue