Skip to content

Commit 2bc9680

Browse files
feat(2019-day-01): solution
1 parent 7099e12 commit 2bc9680

File tree

2 files changed

+118
-0
lines changed

2 files changed

+118
-0
lines changed

2019/day-01/part-1/input.txt

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
114739
2+
132732
3+
123925
4+
146385
5+
72590
6+
51932
7+
64164
8+
72919
9+
97336
10+
101791
11+
101477
12+
95677
13+
89907
14+
76998
15+
60782
16+
109021
17+
138070
18+
113374
19+
68672
20+
133830
21+
134079
22+
89079
23+
72321
24+
142643
25+
102734
26+
103743
27+
77864
28+
111363
29+
72140
30+
64483
31+
139567
32+
141318
33+
132736
34+
87824
35+
81937
36+
123404
37+
56730
38+
54447
39+
63602
40+
84561
41+
145159
42+
93598
43+
137770
44+
52943
45+
146307
46+
91674
47+
143183
48+
52543
49+
143052
50+
107171
51+
80699
52+
130825
53+
141406
54+
75771
55+
123497
56+
87982
57+
144545
58+
125153
59+
147925
60+
106898
61+
60193
62+
111251
63+
102454
64+
135886
65+
141408
66+
84556
67+
94143
68+
97958
69+
86474
70+
96848
71+
126314
72+
51037
73+
140379
74+
142065
75+
73629
76+
102432
77+
123801
78+
68146
79+
107720
80+
51512
81+
123873
82+
104308
83+
59601
84+
149175
85+
80400
86+
76822
87+
116115
88+
87990
89+
90592
90+
68688
91+
133868
92+
78357
93+
91425
94+
149328
95+
123010
96+
93278
97+
101150
98+
120352
99+
107642
100+
136050

2019/day-01/part-1/solution.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const fs = require('fs')
2+
const path = require('path')
3+
const filePath = path.join(__dirname, 'input.txt')
4+
const { calculateFuel } = require('./fuel-calculator')
5+
const { parseData } = require('../../../2018/inputParser')
6+
7+
fs.readFile(filePath, { encoding: 'utf8' }, (err, data) => {
8+
if (err) throw err
9+
10+
data = parseData(data.trim())
11+
12+
const answer = data.reduce((prev, cur) => {
13+
return prev + calculateFuel(parseInt(cur))
14+
}, 0)
15+
16+
console.log('-- Part 1 --')
17+
console.log(`Answer: ${answer}`)
18+
})

0 commit comments

Comments
 (0)