-
Notifications
You must be signed in to change notification settings - Fork 0
/
day01.py
45 lines (37 loc) · 1.21 KB
/
day01.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
#!/usr/bin/env python3
"""
Solution to Day 1 of Advent of Code
"""
__author__ = "Stephanie"
__email__ = "[email protected]"
def main():
with open('day01input.txt', 'r') as f:
entries = f.read().split()
# print(entries)
entries_num = list(map(lambda x:int(x), entries))
# print(entries_num)
sum_2020 = []
for num1 in entries_num:
for num2 in entries_num:
if num1 + num2 == 2020:
if num1 not in sum_2020 and num2 not in sum_2020:
sum_2020.append(num1)
sum_2020.append(num2)
# print(sum_2020)
product_2020 = sum_2020[0]*sum_2020[1]
print(product_2020)
sum_2020 = []
for num1 in entries_num:
for num2 in entries_num:
for num3 in entries_num:
if num1 + num2 + num3 == 2020:
if num1 not in sum_2020 and num2 not in sum_2020 and num3 not in sum_2020:
sum_2020.append(num1)
sum_2020.append(num2)
sum_2020.append(num3)
print(sum_2020)
product_2020 = sum_2020[0]*sum_2020[1]*sum_2020[2]
print(product_2020)
# calling main() function
if __name__ == "__main__":
main()