advent/2020/1/solution.py

25 lines
607 B
Python

#!/usr/bin/python
fd = open("input", "r")
lines = fd.readlines()
lines = [i.rstrip() for i in lines]
mustbreak = False
def part1():
for i in lines:
for j in lines:
if int(i) + int(j) == 2020:
print("{} * {} = {}".format(int(i), int(j), int(i) * int(j)))
return
def part2():
for i in lines:
for j in lines:
for k in lines:
if int(i) + int(j) + int(k) == 2020:
print("{} * {} * {} = {}".format(int(i), int(j), int(k), int(i) * int(j) * int(k)))
return
part1()
part2()