-
Notifications
You must be signed in to change notification settings - Fork 0
/
day1.py
52 lines (36 loc) · 1.14 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
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
"""
Advent of Code, Day 1
input: list of numbers, see d1_test.txt
todo:
part 1: find the two numbers, that sum up to 2020, multiply them and submit the result
part 2: find the three numbers from the list that sum up to 2020, multiply them and submit the result
results on testset:
part 1: 514579
part 2: 241861950
"""
import sys
##Part 1
def run_part1(input):
for aline in input:
for secondline in input:
aline = int(aline)
secondline = int(secondline)
#print(aline)
if aline + secondline == 2020:
print(aline * secondline)
## PArt 2
def run_part2(input):
for aline in input:
for secondline in input:
for thirdline in input:
aline = int(aline)
secondline = int(secondline)
thirdline = int(thirdline)
if aline + secondline + thirdline == 2020:
print(aline * secondline * thirdline)
if __name__ == "__main__":
inputtxt = sys.argv[1]
with open(inputtxt,'r') as inp:
input = inp.readlines()
run_part1(input)
run_part2(input)