」 feat(2025/02): day2 git add . damn was not that hard and im proud of part2 hehe

This commit is contained in:
2025-12-02 12:07:22 +01:00
parent 6306ab23d1
commit 0fef7cade7
2 changed files with 40 additions and 0 deletions

20
2025/02/part1.py Normal file
View File

@@ -0,0 +1,20 @@
import os
from collections import Counter
if (os.path.isfile("./input")):
input = open("./input", "r").read()
else:
input = "11-22,95-115,998-1012,1188511880-1188511890,222220-222224,1698522-1698528,446443-446449,38593856-38593862,565653-565659,824824821-824824827,2121212118-2121212124"
result = 0
for r in input.split(','):
r = r.split('-')
for i in range(int(r[0]), int(r[1]) + 1):
s = str(i)
if (s[:len(s) // 2 + len(s) % 2] == s[len(s) // 2 + len(s) % 2:]):
result += i;
print(result)

20
2025/02/part2.py Normal file
View File

@@ -0,0 +1,20 @@
import os
from collections import Counter
if (os.path.isfile("./input")):
input = open("./input", "r").read()
else:
input = "11-22,95-115,998-1012,1188511880-1188511890,222220-222224,1698522-1698528,446443-446449,38593856-38593862,565653-565659,824824821-824824827,2121212118-2121212124"
result = 0
for r in input.split(','):
r = r.split('-')
for i in range(int(r[0]), int(r[1]) + 1):
s = str(i)
if (s in (s + s)[1:-1]):
result += i;
print(result)