-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path001.py
38 lines (24 loc) · 792 Bytes
/
001.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
import aoc_help as aoc
def find_remainders(report, total = 2020):
return [total - entry for entry in report]
def find_two(report, total = 2020):
remainders = find_remainders(report, total)
entries = list(set(remainders).intersection(set(report)))
return entries
def find_three(report):
result = []
for entry in report:
partial_entries = find_two(report, 2020 - entry)
if len(partial_entries) == 2:
result.append(entry)
return result
# read input
report = aoc.get_input('001')
report = report.split('\n')
report = [int(entry) for entry in report]
# first part of the day
entries = find_two(report)
print(entries[0] * entries[1])
# second part of the day
result = find_three(report)
print(result[0] * result[1] * result [2])