35 lines
773 B
Python
35 lines
773 B
Python
#!/usr/bin/python3
|
|
import sys
|
|
import re
|
|
|
|
alph_num_dict = {
|
|
'a': '2', 'b': '2', 'c': '2',
|
|
'd': '3', 'e': '3', 'f': '3',
|
|
'g': '4', 'h': '4', 'i': '4',
|
|
'j': '5', 'k': '5', 'l': '5',
|
|
'm': '6', 'n': '6', 'o': '6',
|
|
'p': '7', 'q': '7', 'r': '7',
|
|
's': '7',
|
|
'u': '8', 'w': '9', 'v': '8',
|
|
'w': '9', 'x': '9', 'y': '9',
|
|
'z': '9', ' ': ' '
|
|
}
|
|
|
|
def translate(text):
|
|
response = ""
|
|
for i in text.lower()[::-1]:
|
|
response += alph_num_dict[i]
|
|
return response
|
|
|
|
def is_number(text):
|
|
pattern = re.compile(r'^[A-Z]{5} [A-Z]{4}$')
|
|
|
|
result = re.match(pattern, text)
|
|
if result and translate(text)!=translate("HORSE HEAD"):
|
|
return "yes"
|
|
else:
|
|
return "no"
|
|
|
|
for line in sys.stdin:
|
|
print(is_number(line))
|