automata-labs/TaskC48/solution.py
eddie b519e4ce13 Solve TaskC48
Zavod...
2024-12-18 18:30:40 +01:00

18 lines
683 B
Python

import re
import sys
def is_pokemon(line: str) -> bool:
# Defining lowercase and uppercase sets, with Polish diacritic letters included.
lowercase = "a-ząćęłńóśźż"
uppercase = "A-ZĄĆĘŁŃÓŚŹŻ"
# Note: I tried to use a single regex pattern as requested.
# It turned to be kinda complicated! It relies on preventing identical cases appearing in a row, thus switching case.
p = re.compile(fr'^([{uppercase}]?(?:[{lowercase}][{uppercase}])+[{lowercase}]?)')
return bool(p.match(line))
if __name__ == "__main__":
for line in sys.stdin:
stripped_line = line.strip()
print("yes" if is_pokemon(stripped_line) else "no")