Skip to content

Instantly share code, notes, and snippets.

@goose121
Created December 1, 2019 18:29
Show Gist options
  • Save goose121/1ad5cb7c9483531e0d4cee3b631c35fd to your computer and use it in GitHub Desktop.
Save goose121/1ad5cb7c9483531e0d4cee3b631c35fd to your computer and use it in GitHub Desktop.
Advent of Code 2019 Day 1, Part 2
(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