-
Notifications
You must be signed in to change notification settings - Fork 0
/
day1.py
31 lines (27 loc) · 839 Bytes
/
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
with open("input/day1", "r") as input:
data = input.read().split("\n")
data.pop()
data = [int(entry) for entry in data]
def part1():
for i in range(len(data)):
for j in range(i + 1, len(data)):
v1 = data[i]
v2 = data[j]
if v1 + v2 == 2020:
print("Part 1: " + str(v1 * v2))
return
def part2():
for i in range(len(data)):
for j in range(i + 1, len(data)):
v1 = data[i]
v2 = data[j]
if v1 + v2 <= 2020:
for k in range(len(data)):
if k == i or k == j:
continue
v3 = data[k]
if v1 + v2 + v3 == 2020:
print("Part 2: " + str(v1 * v2 * v3))
return
part1()
part2()