-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDay10.py
31 lines (24 loc) · 796 Bytes
/
Day10.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# What is the number of 1-jolt differences multiplied by the number of 3-jolt differences?
adapters = [0]
while True:
line = input()
if line == "end":
break
adapters.append(int(line))
adapters.append(max(adapters) + 3)
def part_one():
adapters.sort()
jolt_diff = [curr - prev for prev, curr in zip(adapters[:-1], adapters[1:])]
return jolt_diff.count(1) * jolt_diff.count(3)
def part_two():
adapters.sort()
total_options = []
def find_combination(pos):
options = list(x for x in adapters if adapters[pos] < x <= adapters[pos] + 3)
if len(options) == 0:
total_options.append(1)
for option in options:
pos += 1
find_combination(pos)
find_combination(0)
return sum(total_options)