22 lines
452 B
Python
Executable File
22 lines
452 B
Python
Executable File
#!/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)
|