advent-of-code/2020/01/d1.py
kageru 9932b57d24
Make day1 python less braindead
I know it was just a quick and dirty solution to get an answer within
the first few minutes, but I just can’t leave it like that.
2020-12-01 17:23:08 +01:00

16 lines
386 B
Python

from itertools import combinations
with open('input') as f:
lines = list(map(int, f.readlines()))
def p1(lines):
a, b = filter(lambda t: t[0] + t[1] == 2020, combinations(lines, 2)).__next__()
return a * b
def p2(lines):
a, b, c = filter(lambda t: t[0] + t[1] + t[2] == 2020, combinations(lines, 3)).__next__()
return a * b * c
print(p1(lines))
print(p2(lines))