aboutsummaryrefslogtreecommitdiff
path: root/2021/08/puzzle-2.py
diff options
context:
space:
mode:
authorThomas Voss <thomasvoss@live.com> 2021-12-08 10:47:52 +0100
committerThomas Voss <thomasvoss@live.com> 2021-12-08 10:47:52 +0100
commit01274303075bb131aafb1977ae69a4c871f9e9c4 (patch)
tree8093d970712ba855321b3881a7dceac7c065d4da /2021/08/puzzle-2.py
parente7e3c391a13c96b1b0553078b784167eab06999e (diff)
More golfing
Diffstat (limited to '2021/08/puzzle-2.py')
-rwxr-xr-x2021/08/puzzle-2.py8
1 files changed, 2 insertions, 6 deletions
diff --git a/2021/08/puzzle-2.py b/2021/08/puzzle-2.py
index 0139049..687c2a7 100755
--- a/2021/08/puzzle-2.py
+++ b/2021/08/puzzle-2.py
@@ -34,11 +34,9 @@ def solve(nums: list[str]) -> int:
nummap[9] = s
else:
nummap[0] = s
-
- nums = nums[nums.index("|") + 1 :]
acc = 0
- for n, (k, v) in itertools.product(nums, nummap.items()):
+ for n, (k, v) in itertools.product(nums[nums.index("|") + 1 :], nummap.items()):
if set(n) == v:
acc = acc * 10 + k
return acc
@@ -46,9 +44,7 @@ def solve(nums: list[str]) -> int:
def main() -> None:
with open("input", "r", encoding="utf-8") as f:
- data = list(map(lambda l: l.strip().split(), f.readlines()))
-
- print(sum(solve(line) for line in data))
+ print(sum(solve(line) for line in map(lambda l: l.strip().split(), f.readlines())))
if __name__ == "__main__":