-
Notifications
You must be signed in to change notification settings - Fork 0
/
1.py
239 lines (229 loc) · 1.72 KB
/
1.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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
lines = """
1211
1698
1787
1947
1888
444
1819
1890
1940
1884
1917
1814
1724
1561
1823
1266
1982
1826
1871
1692
1665
1081
1847
640
1861
1632
1916
1921
1450
1806
1950
1969
1757
1766
1799
422
1865
1934
1954
1640
1743
1812
1745
1574
1904
1510
1491
1977
1727
1979
1842
1784
1655
1991
1296
1849
1863
1886
1696
1716
1679
1848
1540
1780
1926
1986
1898
1448
315
1568
1869
1875
2010
1268
1892
1248
1746
1987
1963
20
1575
1827
1653
1851
1365
1599
1688
1943
1677
1320
154
1490
1737
1573
1908
1667
1151
1761
1587
1924
1941
1731
1669
1857
1723
1880
1970
1791
1928
1942
1816
1989
1832
1911
1711
1817
1893
896
1998
1720
317
1964
1379
1750
1971
1322
1992
1347
1608
1373
1668
1252
373
1968
1754
1709
1988
1946
1537
1758
1830
624
1694
1914
1867
1145
1973
1769
1773
1424
1777
1659
1789
1907
1201
1967
1682
1952
1978
1937
1974
1488
1896
1657
1420
1935
1778
1822
1703
2003
119
1149
1732
1878
1938
1918
1797
1836
1741
1579
1589
1999
1772
1853
1793
1768
1759
1216
1765
1944
1735
1580
1756
1308
1786
1962
1981
1156
1948
1894
"""
lines = lines.strip()
lines = [int(line) for line in lines.split("\n")]
def timer(fn):
def function_wrapper(x):
import datetime
begin_time = datetime.datetime.now()
result = fn(x)
delta_time = datetime.datetime.now() - begin_time
print(delta_time)
return result
return function_wrapper
@timer
def part1(numbers):
for i in numbers:
for j in numbers:
if i + j == 2020:
return i * j
@timer
def part2(numbers):
numbers.sort()
for i in numbers:
for j in numbers:
for k in numbers:
if i + j + k == 2020:
return i * j * k
print(f"Answer 1: {part1(lines)}")
print(f"Answer 2: {part2(lines)}")