aboutsummaryrefslogtreecommitdiff
path: root/2021
diff options
context:
space:
mode:
authorThomas Voss <thomasvoss@live.com> 2021-12-03 07:13:56 +0100
committerThomas Voss <thomasvoss@live.com> 2021-12-03 07:13:56 +0100
commit49329c308630de66cd911edfe759ee82e8f084b5 (patch)
tree77de2b23d06620d207f7d01a5f55e1ebcbe27177 /2021
parent8b8e8e053ef8031cbba8a8409a714bfa3196651f (diff)
Perform epic gamer code compression
Diffstat (limited to '2021')
-rwxr-xr-x2021/03/puzzle-2.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/2021/03/puzzle-2.py b/2021/03/puzzle-2.py
index c5ae894..55513dd 100755
--- a/2021/03/puzzle-2.py
+++ b/2021/03/puzzle-2.py
@@ -10,10 +10,10 @@ def solve(lines: list[str], comp: Callable[[int, int], bool]) -> int:
if len(lines) == 1:
return int(lines[0], 2)
- ones = len([line for line in lines if line[i] == "1"])
- zeros = len([line for line in lines if line[i] == "0"])
-
- if comp(zeros, ones):
+ if comp(
+ len([line for line in lines if line[i] == "0"]),
+ len([line for line in lines if line[i] == "1"]),
+ ):
lines = [line for line in lines if line[i] == "0"]
else:
lines = [line for line in lines if line[i] == "1"]