-
Notifications
You must be signed in to change notification settings - Fork 0
/
day1.py
22 lines (14 loc) · 1.02 KB
/
day1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/local/bin/python3
import math
result = 0
masses = [56123, 145192, 123702, 66722, 148748, 53337, 147279, 126828, 118438, 54030, 145839, 87751, 58832, 90085, 113196, 104802, 61235, 136935, 108620, 60795, 107908, 123023, 142399, 131074, 123411, 122653, 84776, 100891, 78816, 62762, 92077, 91428, 56831, 65122, 94694, 78668, 112506, 73406, 118239, 57897, 59200, 54437, 55185, 102667, 86076, 80655, 83406, 141502, 67171, 88472,
149260, 68395, 56828, 108798, 125682, 68203, 118263, 101824, 94853, 68536, 95646, 120283, 135355, 82701, 92243, 122282, 55760, 129959, 142814, 56599, 70836, 69996, 85262, 126648, 69043, 67460, 119934, 82453, 147012, 72957, 53374, 97577, 59696, 121630, 122666, 116591, 145967, 75699, 85963, 140970, 75612, 78792, 100795, 92034, 132569, 117172, 134179, 109504, 103707, 54664]
def masstofuel(mass):
fuel = math.trunc(mass/3)-2
if fuel > 5:
fuel += masstofuel(fuel)
return fuel
if __name__ == "__main__":
for mass in masses:
result += masstofuel(mass)
print(result)