2020/Day 10/one.py

22 lines
452 B
Python
Raw Normal View History

2022-07-01 15:56:12 +02:00
#!/bin/python
with open("input", 'r') as input:
adapters = [int(i.strip()) for i in input]
adapters.sort()
adapters.insert(0, 0)
adapters.append(adapters[-1]+3)
print(adapters)
i = 0
ones = 0
threes = 0
while i < len(adapters)-1:
if adapters[i+1] - adapters[i] == 1:
ones += 1
elif adapters[i+1] - adapters[i] == 3:
threes += 1
i += 1
print(ones * threes)