rename n.py -> 0n.py
This commit is contained in:
31
2015/05.py
Normal file
31
2015/05.py
Normal file
@@ -0,0 +1,31 @@
|
||||
import re
|
||||
|
||||
# Fill Input
|
||||
|
||||
input = ""
|
||||
|
||||
try:
|
||||
with open("05.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)
|
||||
|
||||
Reference in New Issue
Block a user