]> localhost Git - adventofcode2019.git/blame - src/adventofcode2019/day01.clj
Add broken day16pt2
[adventofcode2019.git] / src / adventofcode2019 / day01.clj
CommitLineData
cca08f5d
JK
1(ns adventofcode2019.day01
2 [:require [adventofcode2019.lib :refer :all]
3 [clojure.string :as str]])
dcb3af31
JK
4
5(defn get-fuel-req [mass]
6 (reduce + (take-while #(> % 0) (drop 1 (iterate #(- (quot % 3) 2) mass)))))
7
8(defn total-fuel-requirement-naive [input]
9 (reduce + (map #(- (quot % 3) 2) input)))
10
11(defn total-fuel-requirement [input]
12 (reduce + (map get-fuel-req input)))
13
cca08f5d
JK
14(defn day01 []
15 (let [input (map parse-int (get-list-from-file (input-file)))]
dcb3af31
JK
16 (println (total-fuel-requirement-naive input))
17 (println (total-fuel-requirement input))))