Day 1
This commit is contained in:
parent
92b4e0b202
commit
189b4894a2
File diff suppressed because it is too large
Load Diff
5
lib.rkt
5
lib.rkt
|
@ -255,6 +255,11 @@
|
|||
(if (zero? m) '()
|
||||
(append lst (repeat (sub1 m) lst))))
|
||||
|
||||
;; mmap : (a -> b) -> (listof (listof a)) -> (listof (listof b))
|
||||
;; Map a list of lists
|
||||
(define (mmap f lst)
|
||||
(map (∂ map f) lst))
|
||||
|
||||
;; chunks-of : (listof any) -> nonzero? -> (listof (listof any))
|
||||
;; Partitions a list into lists of the given size in order,
|
||||
;; with the final list possibly being smaller
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
#lang racket
|
||||
|
||||
(require "../lib.rkt")
|
||||
|
||||
(define input (mmap string->number (problem-input-grouped-lines 1)))
|
||||
|
||||
(define calories (sort (map sum input) >))
|
||||
|
||||
(define part1 (first calories))
|
||||
|
||||
(define part2 (sum (take calories 3)))
|
||||
|
||||
(show-solution part1 part2)
|
Loading…
Reference in New Issue