automata-labs/TaskC03/solution.py
2024-12-18 17:47:53 +01:00

14 lines
383 B
Python

import re
import sys
def is_valid_nip(line: str) -> bool:
# matching either:
# xxx-xxx-xx-xx OR xxx-xx-xx-xxx
p = re.compile(r'^(?:\d{3}-\d{3}-\d{2}-\d{2}|\d{3}-\d{2}-\d{2}-\d{3})$')
return bool(p.match(line))
if __name__ == "__main__":
for line in sys.stdin:
stripped_line = line.strip()
print("yes" if is_valid_nip(stripped_line) else "no")