Add 1 -> 5

This commit is contained in:
PedroEdiaz
2025-10-29 17:19:47 -06:00
commit 62dade14e1
5 changed files with 139 additions and 0 deletions

30
2015/5.py Normal file
View File

@@ -0,0 +1,30 @@
#!/usr/bin/env python3
import re
# Fill Input
input = ""
try:
with open("5.txt", 'r', encoding='utf-8') as file:
input += file.read()
except Exception as e:
print(f"An error occurred: {e}")
# regex matching
def match(pattern, string):
return re.search(pattern, string) != None
# Convert Corrdenate to string
res1, res2 = 0, 0
for line in input.split("\n"):
res1 += int(match(r"(.)\1", line) and
match(r"(.*[aeiou]){3,}", line) and
not match(r"ab|cd|pq|xy", line) )
res2 += int(match(r"(..).*\1", line) and
match(r"(.).\1", line) )
print(res1, res2)