2019/04
author |
Steve Losh <steve@stevelosh.com> |
date |
Wed, 04 Dec 2019 12:04:52 -0500 |
parents |
5b5c61ad8d2b |
children |
(none) |
(defpackage :advent/2019/01 #.cl-user::*advent-use*)
(in-package :advent/2019/01)
(defun fuel-required (module-mass)
(max 0 (- (floor module-mass 3) 2)))
(defun complete-fuel-required (module-mass)
(iterate
(for fuel :first (fuel-required module-mass) :then (fuel-required fuel))
(summing fuel)
(until (zerop fuel))))
(define-problem (2019 1) (data read-all) (3464458 5193796)
(values (summation data :key #'fuel-required)
(summation data :key #'complete-fuel-required)))