From 164b77d657d2cee959434be9618f51f81138f7ce Mon Sep 17 00:00:00 2001 From: "Peter J. Holzer" Date: Sun, 13 Dec 2020 19:20:17 +0100 Subject: [PATCH] Complete day 10 --- 10/part1 | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100755 10/part1 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])