blob: ee84450570e645c7f82615766adcbab3432f6e22 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
; run sbcl --load ~/.sbclrc --script solver.lisp
(ql:quickload '(:uiop :fiveam))
(defun elves-rations ()
(reduce
(lambda (acc value)
(if (string= value "")
(cons 0 acc)
(progn
(incf (car acc) (parse-integer value))
acc)))
(uiop:read-file-lines "input")
:initial-value (list 0)))
(fiveam:test results
(let ((rations (elves-rations)))
;; calculate the maximum from each elves rations
(fiveam:is (= 75622 (apply #'max rations)))
;; calculate the maximum from each elves rations
(fiveam:is (= 213159 (apply #'+ (subseq (sort rations #'>) 0 3))))))
(fiveam:run-all-tests)
|