From fd24f3a8b86cee51802fa33d4366a2de422f7cb6 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Wed, 8 Dec 2021 15:02:58 +0100 Subject: Why am I using a dictionary? --- 2021/08/puzzle-2.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/2021/08/puzzle-2.py b/2021/08/puzzle-2.py index 687c2a7..c90e07c 100755 --- a/2021/08/puzzle-2.py +++ b/2021/08/puzzle-2.py @@ -4,7 +4,7 @@ import itertools def solve(nums: list[str]) -> int: - nummap: dict[str, set[str]] = {} + nummap: list[set[str]] = [None for _ in range(10)] # First pass, find the easy patterns. From these 4 patterns you can determine all other ones for n in nums: @@ -36,9 +36,9 @@ def solve(nums: list[str]) -> int: nummap[0] = s acc = 0 - for n, (k, v) in itertools.product(nums[nums.index("|") + 1 :], nummap.items()): + for n, (i, v) in itertools.product(nums[nums.index("|") + 1 :], enumerate(nummap)): if set(n) == v: - acc = acc * 10 + k + acc = acc * 10 + i return acc -- cgit v1.2.3