1
0
Fork 0
This commit is contained in:
Jonathan Chan 2022-12-01 00:11:38 -05:00
parent 92b4e0b202
commit 189b4894a2
3 changed files with 2272 additions and 0 deletions

2254
input/01.txt Normal file

File diff suppressed because it is too large Load Diff

View File

@ -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

13
src/01.rkt Normal file
View File

@ -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)