This commit is contained in:
Simon Junod
2025-12-02 09:10:53 +01:00
parent ac521091a6
commit 5e9b832698
3 changed files with 33 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
input

16
2/a.py Normal file
View File

@@ -0,0 +1,16 @@
import re
with open("input", "r") as f:
line = f.read()
ranges = line.split(",")
s = 0
for _range in ranges:
start, end = list(map(int, _range.split("-")))
for i in range(start, end+1):
if re.match(r"^(.+)\1$", str(i)):
s += i
print(s)

16
2/b.py Normal file
View File

@@ -0,0 +1,16 @@
import re
with open("input", "r") as f:
line = f.read()
ranges = line.split(",")
s = 0
for _range in ranges:
start, end = list(map(int, _range.split("-")))
for i in range(start, end+1):
if re.match(r"^(.+)\1+$", str(i)):
s += i
print(s)