Complete day 10
This commit is contained in:
parent
be4f880cd3
commit
164b77d657
|
@ -0,0 +1,18 @@
|
|||
#!/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])
|
Loading…
Reference in New Issue