19 lines
376 B
Python
Executable File
19 lines
376 B
Python
Executable File
#!/usr/bin/python3
|
|
|
|
adapters = []
|
|
with open("input") as fh:
|
|
for ln in fh:
|
|
adapters.append(int(ln))
|
|
|
|
adapters = sorted(adapters)
|
|
|
|
last = 0;
|
|
steps = [0, 0, 0, 0]
|
|
for a in adapters:
|
|
assert 1 <= a - last <= 3 # otherwise there is no solution
|
|
steps[a - last] += 1
|
|
last = a
|
|
steps[3] += 1 # last step is always 3
|
|
print(steps[1:4])
|
|
print(steps[1] * steps[3])
|