aoc/2020/01/01.py

24 lines
463 B
Python
Raw Normal View History

def read_file():
2020-12-02 13:11:58 +00:00
with open('input.txt','r') as f:
return [int(x) for x in f]
def part1(expenses):
2020-12-02 13:11:58 +00:00
for a in expenses:
for b in expenses:
if a + b == 2020:
return a*b
def part2(expenses):
2020-12-02 13:11:58 +00:00
for a in expenses:
for b in expenses:
for c in expenses:
if a + b + c == 2020:
return a*b*c
def main():
expenses = read_file()
print(f'Part 1: {part1(expenses)}')
print(f'Part 2: {part2(expenses)}')
2020-12-02 13:11:58 +00:00
if __name__ == "__main__":
main()