aboutsummaryrefslogtreecommitdiff
path: root/2015/18/puzzle-2.py
diff options
context:
space:
mode:
Diffstat (limited to '2015/18/puzzle-2.py')
-rwxr-xr-x2015/18/puzzle-2.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/2015/18/puzzle-2.py b/2015/18/puzzle-2.py
index 9a998b8..b57edb9 100755
--- a/2015/18/puzzle-2.py
+++ b/2015/18/puzzle-2.py
@@ -28,15 +28,16 @@ def simulate(data: list[list[str]]) -> list[list[str]]:
for i in range(100):
for j in range(100):
- if (i, j) in [(0, 0), (0, 99), (99, 0), (99, 99)]:
- ndata[i][j] = "#"
- elif 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 (
+ ((i, j) in [(0, 0), (0, 99), (99, 0), (99, 99)])
+ or (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()]