add solution for TaskC21
This commit is contained in:
parent
7c46eeac38
commit
923a1d5b5c
25
TaskC21_TODO/solution.py
Normal file
25
TaskC21_TODO/solution.py
Normal file
@ -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')
|
Loading…
Reference in New Issue
Block a user