Problem B
Morse Code Palindromes
A Palindrome is a word, number, phrase, or other sequence of characters which reads the same backward as forward, such as madam or racecar or 1881. Phrase palindromes ignore capitalization, punctuation, and word boundaries. For example: Madam I’m Adam.
Morse code is a method used in telecommunication to encode text characters as standardized sequences of two different signal durations, called dots and dashes, or dits and dahs. Morse code is named after Samuel Morse, one of the inventors of the telegraph. The international morse code for letters and digits is:
(Note that the code for upper and lower case letters is the same.)
A word, number or phrase is a Morse Code Palindrome if the morse code for the letters and digits in the word, number or phrase reads the same backwards and forwards (ignoring spaces between character codes). For example:
159
Footstool
A E
Determine if an input string is a Morse Code Palindrome.
Input
The single input line contains a string of up to $80$ ASCII characters, possibly including spaces and other non-alphanumeric printable characters.
Output
The single output line consists of the integer 1 if the input string (ignoring everything but letters and digits) is a Morse Code Palindrome. Otherwise the output line consists of the integer 0. If there are no letters or digits in the input string, the output should be 0.
Sample Input 1 | Sample Output 1 |
---|---|
hello |
0 |
Sample Input 2 | Sample Output 2 |
---|---|
159 |
1 |
Sample Input 3 | Sample Output 3 |
---|---|
Madam I'm Adam |
0 |
Sample Input 4 | Sample Output 4 |
---|---|
footstool |
1 |
Sample Input 5 | Sample Output 5 |
---|---|
SOS |
1 |
Sample Input 6 | Sample Output 6 |
---|---|
A E |
1 |