diff options
author | Thomas Voss <thomasvoss@live.com> | 2021-10-29 23:17:45 +0200 |
---|---|---|
committer | Thomas Voss <thomasvoss@live.com> | 2021-10-29 23:17:45 +0200 |
commit | f61b65581c30879a9bfa43ffafb99d4ba160cd32 (patch) | |
tree | 7be11a117789df3b8c966b989b64b5e7938b0010 /2015/18/puzzle-1.py | |
parent | a5abae53a8be58f1b4e19d69d75350b79216f252 (diff) |
Squash if/elif chains into a single if check
Diffstat (limited to '2015/18/puzzle-1.py')
-rwxr-xr-x | 2015/18/puzzle-1.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/2015/18/puzzle-1.py b/2015/18/puzzle-1.py index ef6d36e..3fe9c8a 100755 --- a/2015/18/puzzle-1.py +++ b/2015/18/puzzle-1.py @@ -28,13 +28,14 @@ def simulate(data: list[list[str]]) -> list[list[str]]: for i in range(100): for j in range(100): - if data[i][j] == "#" and neighbours(data, i, j) in [2, 3]: - ndata[i][j] = "#" - elif data[i][j] == "." and neighbours(data, i, j) == 3: + if (data[i][j] == "#" and neighbours(data, i, j) in [2, 3]) or ( + data[i][j] == "." and neighbours(data, i, j) == 3 + ): ndata[i][j] = "#" return ndata + def main() -> None: with open("input", "r", encoding="utf-8") as f: data = [list(l.strip()) for l in f.readlines()] |