diff options
author | Thomas Voss <thomasvoss@live.com> | 2021-12-08 15:02:58 +0100 |
---|---|---|
committer | Thomas Voss <thomasvoss@live.com> | 2021-12-08 15:02:58 +0100 |
commit | fd24f3a8b86cee51802fa33d4366a2de422f7cb6 (patch) | |
tree | 617a570b40b3b424bffe9eae58f936ed4a109c0b /2021 | |
parent | 01274303075bb131aafb1977ae69a4c871f9e9c4 (diff) |
Why am I using a dictionary?
Diffstat (limited to '2021')
-rwxr-xr-x | 2021/08/puzzle-2.py | 6 |
1 files 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 |