aboutsummaryrefslogtreecommitdiff
path: root/2025/02/a.py
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2025-12-02 06:15:47 +0100
committerSebastiano Tronto <sebastiano@tronto.net>2025-12-02 06:37:33 +0100
commitc0c0f809bb5b2327db96c7dbb5e9ef8ea5960b00 (patch)
treef0ae0f3e09b748aafb3effba7051eb8e136c55e1 /2025/02/a.py
parent8e716a225ece98cf75cc1789c8f90757c0beadfc (diff)
downloadaoc-c0c0f809bb5b2327db96c7dbb5e9ef8ea5960b00.tar.gz
aoc-c0c0f809bb5b2327db96c7dbb5e9ef8ea5960b00.zip
Day 2 2025 (solved part 2 before part 1 because I misread lol)
Diffstat (limited to '')
-rw-r--r--2025/02/a.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/2025/02/a.py b/2025/02/a.py
index 5fdb11b..9c6fd84 100644
--- a/2025/02/a.py
+++ b/2025/02/a.py
@@ -1,6 +1,17 @@
1import fileinput 1import fileinput
2 2
3def invalid(n):
4 return n[:len(n)//2] == n[len(n)//2:]
5
6s = 0
3with fileinput.input() as lines: 7with fileinput.input() as lines:
4 for line in lines: 8 for line in lines:
5 ... 9 for r in line.split(","):
10 l = r.split("-");
11 for n in range(int(l[0]), int(l[1])+1):
12 if invalid(str(n)):
13 print(n)
14 s += n
15print(s)
16
6 17

Generated with cgit - Back to sebastiano.tronto.net