aboutsummaryrefslogtreecommitdiff
path: root/2025/04
diff options
context:
space:
mode:
Diffstat (limited to '2025/04')
-rw-r--r--2025/04/a.py11
-rw-r--r--2025/04/b.py11
2 files changed, 12 insertions, 10 deletions
diff --git a/2025/04/a.py b/2025/04/a.py
index a693841..8ffad35 100644
--- a/2025/04/a.py
+++ b/2025/04/a.py
@@ -7,13 +7,14 @@ def neigh(a, i, j):
7 a[i+1][j-1], a[i+1][j], a[i+1][j+1], 7 a[i+1][j-1], a[i+1][j], a[i+1][j+1],
8 ].count('@') 8 ].count('@')
9 9
10s = 0
11with fileinput.input() as lines: 10with fileinput.input() as lines:
12 a = [['.'] * 200] 11 a = [
13 for line in lines: 12 ['.'] * 200,
14 a.append(['.'] + list(line.replace('\n', '.'))) 13 *[['.'] + list(line.replace('\n', '.')) for line in lines],
15 a.append(['.'] * 200) 14 ['.'] * 200,
15 ]
16 16
17s = 0
17for i in range(1,len(a)-1): 18for i in range(1,len(a)-1):
18 for j in range(1,len(a[1])-1): 19 for j in range(1,len(a[1])-1):
19 if a[i][j] == '@' and neigh(a, i, j) < 4: 20 if a[i][j] == '@' and neigh(a, i, j) < 4:
diff --git a/2025/04/b.py b/2025/04/b.py
index 93b1fff..583c076 100644
--- a/2025/04/b.py
+++ b/2025/04/b.py
@@ -7,13 +7,14 @@ def neigh(a, i, j):
7 a[i+1][j-1], a[i+1][j], a[i+1][j+1], 7 a[i+1][j-1], a[i+1][j], a[i+1][j+1],
8 ].count('@') 8 ].count('@')
9 9
10s = 0
11with fileinput.input() as lines: 10with fileinput.input() as lines:
12 a = [['.'] * 200] 11 a = [
13 for line in lines: 12 ['.'] * 200,
14 a.append(['.'] + list(line.replace('\n', '.'))) 13 *[['.'] + list(line.replace('\n', '.')) for line in lines],
15 a.append(['.'] * 200) 14 ['.'] * 200,
15 ]
16 16
17s = 0
17rem = True 18rem = True
18while rem: 19while rem:
19 rem = False 20 rem = False

Generated with cgit - Back to sebastiano.tronto.net