Skip to content

Commit 4783d74

Browse files
committed
aoc2019 day1
1 parent a028875 commit 4783d74

File tree

2 files changed

+124
-0
lines changed

2 files changed

+124
-0
lines changed

resources/2019/day01

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
130762
2+
108691
3+
131618
4+
138163
5+
59967
6+
130453
7+
117515
8+
115776
9+
134083
10+
86966
11+
128075
12+
55569
13+
112843
14+
97878
15+
92330
16+
70917
17+
143903
18+
81171
19+
148506
20+
141379
21+
131161
22+
88719
23+
69654
24+
82141
25+
55265
26+
75623
27+
97408
28+
105269
29+
147378
30+
126054
31+
133962
32+
60304
33+
130503
34+
138350
35+
93164
36+
69661
37+
69271
38+
100054
39+
138295
40+
142865
41+
64142
42+
123466
43+
80101
44+
149696
45+
102510
46+
129988
47+
87742
48+
106785
49+
133039
50+
59192
51+
86544
52+
124950
53+
64242
54+
80128
55+
109287
56+
129634
57+
140335
58+
118220
59+
106819
60+
97296
61+
111003
62+
103222
63+
54192
64+
103548
65+
63861
66+
140571
67+
50476
68+
100570
69+
114065
70+
110279
71+
64720
72+
91941
73+
62312
74+
80834
75+
132969
76+
51973
77+
115887
78+
68662
79+
138266
80+
107234
81+
75795
82+
81409
83+
78610
84+
112587
85+
92384
86+
111804
87+
138861
88+
79393
89+
81285
90+
131307
91+
68815
92+
54976
93+
127529
94+
103359
95+
138537
96+
79663
97+
128097
98+
56085
99+
96504
100+
119501

src/aoc19/day01.clj

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
(ns aoc19.day01
2+
(:require [clojure.java.io :as io]
3+
[clojure.string :as str]))
4+
5+
(def input (->> (io/resource "2019/day01")
6+
slurp
7+
str/split-lines
8+
(map #(Integer/valueOf %))))
9+
10+
(defn fuel [mass] (- (quot mass 3) 2))
11+
12+
(defn total-fuel [mass]
13+
(->> (iterate fuel mass)
14+
(take-while pos?)
15+
rest
16+
(apply +)))
17+
18+
; part 1
19+
(apply + (map fuel input))
20+
; 3399394
21+
22+
; part 2
23+
(apply + (map total-fuel input))
24+
; 15295091

0 commit comments

Comments
 (0)