Created
December 1, 2019 18:29
-
-
Save goose121/1ad5cb7c9483531e0d4cee3b631c35fd to your computer and use it in GitHub Desktop.
Advent of Code 2019 Day 1, Part 2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun fuel-for-mass (mass) | |
(- (floor mass 3) 2)) | |
(defun total-fuel-for-mass (mass) | |
(loop :for current-mass = (fuel-for-mass mass) | |
:then (fuel-for-mass current-mass) | |
:until (minusp current-mass) | |
:sum current-mass)) | |
(defun part-2 (stream) | |
(loop :for line = (read-line stream nil) | |
:while line | |
:sum (total-fuel-for-mass (parse-integer line)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment