You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
387 B
Python
19 lines
387 B
Python
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]])
|