Let’s bring back Santa from the edge of the solar system
Part 1
; First we need to calculate the fuel per mass:
(defn fuel-for-mass [mass]
(- (Math/floor (/ mass 3)) 2))
; Then we need to sum up the fuel for all the modules
(defn day1-1 [input]
(->> input
(map fuel-for-mass)
(reduce +)))
Part 2
; Recursively calculate the additional fuel requirement the fuel
(defn fuel-for-module [mass]
(let [fuel (fuel-for-mass mass)]
(if (> fuel 0)
(+ fuel (fuel-for-module fuel))
0)))
(defn day1-2 [input]
(->> input
(map fuel-for-module)
(reduce +)))