Skip to content

Commit dc3a682

Browse files
committed
Add 2019 puzzle
1 parent be248bf commit dc3a682

File tree

6 files changed

+131
-0
lines changed

6 files changed

+131
-0
lines changed

2019/1/first/go.mod

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module github.com/garritfra/adventofcode2019/1
2+
3+
go 1.15

2019/1/first/input.txt

+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
86608
2+
97271
3+
51200
4+
149104
5+
86406
6+
97844
7+
74380
8+
125817
9+
56605
10+
125891
11+
63835
12+
131033
13+
142276
14+
126174
15+
78742
16+
113961
17+
126933
18+
105209
19+
116007
20+
88301
21+
89203
22+
109951
23+
100609
24+
68863
25+
106611
26+
86765
27+
50887
28+
80834
29+
126291
30+
87119
31+
137577
32+
123005
33+
135688
34+
66530
35+
106270
36+
94168
37+
92881
38+
51170
39+
59598
40+
60445
41+
71249
42+
86492
43+
141475
44+
137397
45+
149715
46+
99862
47+
144797
48+
135188
49+
133640
50+
96909
51+
85245
52+
107849
53+
126123
54+
112848
55+
76667
56+
112760
57+
121517
58+
75878
59+
82591
60+
116926
61+
56514
62+
131864
63+
148794
64+
139636
65+
106349
66+
76418
67+
83862
68+
142732
69+
139332
70+
142236
71+
108925
72+
130420
73+
59682
74+
72933
75+
50265
76+
99444
77+
52089
78+
57686
79+
75440
80+
51043
81+
149777
82+
108662
83+
146667
84+
90802
85+
147235
86+
91776
87+
76203
88+
67766
89+
68173
90+
103707
91+
54682
92+
145674
93+
135349
94+
58766
95+
92270
96+
126388
97+
111236
98+
69184
99+
66915
100+
117342

2019/1/first/main.go

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"io/ioutil"
6+
"math"
7+
"strconv"
8+
"strings"
9+
)
10+
11+
func main() {
12+
data, err := ioutil.ReadFile("input.txt")
13+
if err != nil {
14+
fmt.Println("File reading error", err)
15+
return
16+
}
17+
lines := strings.Split(string(data), "\n")
18+
19+
sum := 0.0
20+
21+
for _, line := range lines {
22+
fuel, _ := strconv.Atoi(line)
23+
result := math.Floor(float64(fuel)/3) - 2
24+
sum += result
25+
}
26+
27+
fmt.Println(int(sum))
28+
}
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)