-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathday1_1.swift
112 lines (110 loc) · 1.3 KB
/
day1_1.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
let input = [
94735,
80130,
127915,
145427,
89149,
91232,
100629,
97340,
86278,
87034,
147351,
123045,
91885,
85973,
64130,
113244,
58968,
76296,
127931,
98145,
120731,
98289,
110340,
118285,
60112,
57177,
58791,
59012,
66950,
139387,
145378,
86204,
147082,
84956,
134161,
148664,
74278,
96746,
144525,
81214,
70966,
107050,
134179,
138587,
80236,
139871,
104439,
64643,
145453,
94791,
51690,
94189,
148476,
79956,
81760,
149796,
109544,
57533,
142999,
126419,
115434,
57092,
64244,
109663,
94701,
109265,
145851,
95183,
84433,
53818,
106234,
127380,
149774,
59601,
138851,
54488,
100877,
136952,
61538,
67705,
60299,
130769,
113176,
106723,
133280,
111065,
63688,
139307,
122703,
60162,
89567,
63994,
66608,
126376,
136052,
112255,
98525,
134023,
141479,
98200,
]
func getFuel(for module: Int) -> Int {
return (module/3) - 2
}
var totalFuel = 0
for module in input {
totalFuel += getFuel(for: module)
}
print(totalFuel)