aboutsummaryrefslogtreecommitdiff
path: root/2025/04/a.py
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2025-12-04 10:38:46 +0100
committerSebastiano Tronto <sebastiano@tronto.net>2025-12-04 10:38:46 +0100
commit10caeb18b9c224c8b42ca724e956dba35807ec2c (patch)
treef8ce59df5b4e654854e4d6d2d6fe428b75f16483 /2025/04/a.py
parentbc79fa83d3cb63d8445312b47dbed9295809b28a (diff)
downloadaoc-10caeb18b9c224c8b42ca724e956dba35807ec2c.tar.gz
aoc-10caeb18b9c224c8b42ca724e956dba35807ec2c.zip
Small cleanup
Diffstat (limited to '2025/04/a.py')
-rw-r--r--2025/04/a.py11
1 files changed, 6 insertions, 5 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:

Generated with cgit - Back to sebastiano.tronto.net