advent-of-code/2020/10/solution2.py

19 lines
387 B
Python
Raw Normal View History

2020-12-10 20:19:58 +01:00
from collections import defaultdict
with open('input', 'r') as f:
adapters = list(map(int, f.readlines()))
adapters.append(0)
adapters.sort()
adapters.append(adapters[-1] + 3)
print(adapters)
countMap = defaultdict(int)
countMap[0] = 1
for adapter in adapters:
for target in range(1, 4):
countMap[adapter + target] += countMap[adapter]
print(countMap[adapters[-1]])