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