You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
457 B

import itertools
def main():
with open("day1.txt", "rt") as f:
lines = [line.rstrip() for line in f.readlines()]
values = list(map(lambda l: int(l), lines))
# Part 1
for a, b in itertools.combinations(values, 2):
if a + b == 2020:
print(a * b)
# Part 2
for a, b, c in itertools.combinations(values, 3):
if a + b + c == 2020:
print(a * b * c)
if __name__ == "__main__":
main()