AdventOfCode2020/day1.py

39 lines
729 B
Python
Raw Normal View History

2022-12-14 13:31:08 +01:00
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)