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]])