SHARE
TWEET

Untitled

a guest Dec 1st, 2019 119 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (defn calculate-fuel
  2.   [mass]
  3.   (- (quot mass 3) 2))
  4.  
  5. (defn calculate-total-fuel
  6.   [masses]
  7.   "Solves Pt. 1"
  8.   (reduce + (map calculate-fuel masses)))
  9.  
  10. (defn calculate-extra-fuel
  11.   [mass]
  12.   (reduce + (drop 1 (take-while pos? (iterate calculate-fuel mass)))))
  13.  
  14. (defn calculate-total-extra-fuel
  15.   "Solves Pt. 2"
  16.   [masses]
  17.   (reduce + (map calculate-extra-fuel masses)))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top