24 lines
No EOL
463 B
Python
24 lines
No EOL
463 B
Python
def read_file():
|
|
with open('input.txt','r') as f:
|
|
return [int(x) for x in f]
|
|
|
|
def part1(expenses):
|
|
for a in expenses:
|
|
for b in expenses:
|
|
if a + b == 2020:
|
|
return a*b
|
|
|
|
def part2(expenses):
|
|
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)}')
|
|
|
|
if __name__ == "__main__":
|
|
main() |