summaryrefslogtreecommitdiff
path: root/day1/day1.py
blob: b0623f92a0384fb9ffce88d0e1ddbcc865a7e398 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from functools import reduce
from itertools import combinations


def mult(iterable):
    return reduce(lambda x, y: x * y, iterable)


def find_x_nums(data, sum_value, num):
    for vals in combinations(data, num):
        if sum(vals) == sum_value:
            return vals


data = [int(str.strip(x)) for x in open("input")]

print(mult(find_x_nums(data, 2020, 2)))
print(mult(find_x_nums(data, 2020, 3)))