39 lines
729 B
Python
39 lines
729 B
Python
day = "day1"
|
|
file = f"inputs/{day}.txt"
|
|
|
|
|
|
def part_one(file):
|
|
result = 0
|
|
input = open(file, "r")
|
|
input = input.readlines()
|
|
check_number = 0
|
|
current_number = 0
|
|
|
|
for i in input:
|
|
for j in input:
|
|
if(int(i) + int(j) == 2020):
|
|
result = int(i) * int(j)
|
|
break
|
|
|
|
|
|
|
|
|
|
print(f"Part 1: {result}")
|
|
|
|
part_one(file)
|
|
|
|
|
|
def part_two(file):
|
|
result = 0
|
|
input = open(file, "r")
|
|
input = input.readlines()
|
|
for i in input:
|
|
for j in input:
|
|
for k in input:
|
|
if((int(i) + int(j) + int(k)) == 2020):
|
|
result = int(i) * int(j) * int(k)
|
|
break
|
|
|
|
print(f"Part 2: {result}")
|
|
|
|
part_two(file) |