-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path01.py
127 lines (117 loc) · 1.11 KB
/
01.py
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/usr/bin/env python
with open(__file__, "r") as f:
c = f.read()
lines = iter(c[c.rindex("🎅") + 1 : c.rindex("🐍")].rstrip().split("\n"))
mass = list(map(int, lines))
def fuel(mass):
return mass // 3 - 2
def fuels(mass):
while (mass := fuel(mass)) > 0:
yield mass
part_one = sum(fuel(m) for m in mass)
print(part_one)
assert part_one == 3368364
part_two = sum(f for m in mass for f in fuels(m))
print(part_two)
assert part_two == 5049684
"""🎅102562
138390
145043
86679
120601
58443
54761
81175
127897
69559
56776
145671
69003
119334
130205
77249
74637
92068
66594
90485
140465
73444
107772
107639
144420
58764
56299
66010
84841
83686
139830
136298
135009
136506
61547
73653
136219
138875
95483
91695
146597
121813
131555
145848
139396
141520
54207
86748
98355
67179
59820
137299
92371
74512
110854
111960
63787
114701
63773
127377
128159
120370
138193
106409
135550
107235
56662
99314
69052
131816
138788
96494
73025
148907
85883
86138
86965
55645
119284
80690
69276
116640
108595
50721
94623
93224
137069
130118
97916
82232
137621
97909
74061
140419
101795
69316
64973
90578
118503
100369
🐍"""