31 lines
575 B
Python
31 lines
575 B
Python
#!/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)
|
|
|