diff --git a/10/part1 b/10/part1 new file mode 100755 index 0000000..624fa6e --- /dev/null +++ b/10/part1 @@ -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])