aboutsummaryrefslogtreecommitdiff
path: root/2020/19
diff options
context:
space:
mode:
authorThomas Voss <thomasvoss@live.com> 2021-12-08 15:32:04 +0100
committerThomas Voss <thomasvoss@live.com> 2021-12-08 15:32:04 +0100
commite89223eecb7dbb67a45afccfc843b936be3e3efd (patch)
tree7d17f40c203b07dec8c96a2969443748d6ee3dbd /2020/19
parente806b43689f78c1d7f858d84c2c40b2ddcd67540 (diff)
Optimize the condition, thanks Stefan!
Diffstat (limited to '2020/19')
-rw-r--r--2020/19/puzzles.py9
1 files changed, 2 insertions, 7 deletions
diff --git a/2020/19/puzzles.py b/2020/19/puzzles.py
index f2a4bcf..abd0df2 100644
--- a/2020/19/puzzles.py
+++ b/2020/19/puzzles.py
@@ -21,16 +21,11 @@ def check(test: str, patterns: dict[str, list[str]]) -> bool:
# 42 = 0, 31 = 1
res = search(r"^(0)+(1)+$", search_str)
- return not (not res or search_str.count("0") <= search_str.count("1"))
+ return res and not search_str.count("0") <= search_str.count("1")
def string_divide(string: str, div: int) -> list[str]:
- l: list[str] = []
- for i in range(0, len(string), div):
- l.append(string[i : i + div])
- return l
-
-
+ return [string[i : i + div] for i in range(0, len(string), div)]
# END PART 2