diff --git a/TaskC21_TODO/solution.py b/TaskC21_TODO/solution.py new file mode 100644 index 0000000..d4a998f --- /dev/null +++ b/TaskC21_TODO/solution.py @@ -0,0 +1,25 @@ +# HORSE HEAD -> 46773 4323 +import re +import sys + +pattern = r'^[A-Z][A-Z][A-Z][A-Z][A-Z] [A-Z][A-Z][A-Z][A-Z]$' + +def get_number(c): + result = re.sub(r'[ABC]', '2', c) + result = re.sub(r'[DEF]', '3', result) + result = re.sub(r'[GHI]', '4', result) + result = re.sub(r'[JKL]', '5', result) + result = re.sub(r'[MNO]', '6', result) + result = re.sub(r'[PQRS]', '7', result) + result = re.sub(r'[TUV]', '8', result) + result = re.sub(r'[WXYZ]', '9', result) + return result + +for line in sys.stdin: + line = line.strip() + if not re.match(pattern, line): + print('no') + continue + + num = ''.join(get_number(c) for c in line.replace(' ', '')) + print('yes' if re.match(r'^467734323$', num) else 'no')