# Day 1

For this challenge, we need to find two numbers from our input that sum to 2020, and calculate their multiplication.

In :
```def mul(numbers):
x = 1
for n in numbers:
x *= n
return x```
In :
```def day_1(nums, N = 2):
for numbers in itertools.combinations(nums, N):
if sum(numbers) == 2020:
return mul(numbers)```
In :
`day_1(read_numbers("day-1-example.txt"))`
Out :
`514579`
In :
`day_1(read_numbers("day-1.txt"))`
Out :
`224436`

### Part Two

Part two uses the same input but wants the product of three numbers that add up to 2020.

In :
`day_1(read_numbers("day-1.txt"), 3)`
Out :
`303394260`

# Day 2

### Part one

In :
```def is_valid(line):
num, letter = rule.split(" ")
low, high = num.split("-")
low, high = int(low), int(high)

return count >= low and count <= high```
In :
```def num_valid(path):
valid_lines = map(is_valid, lines)
return sum(valid_lines)```
In :
```num_valid("day-2-example.txt")
num_valid("day-2.txt")```
Out :
`2`
Out :
`528`

### Part two

In :
```def is_valid(line):
rule, pw = line.split(": ")
num, letter = rule.split(" ")
pos1, pos2 = num.split("-")
pos1, pos2 = int(pos1) - 1, int(pos2) - 1

res = int(pw[pos1] == letter)
res += int(pw[pos2] == letter)

return res == 1```
In :
`num_valid("day-2.txt")`
Out :
`497`