next up previous
Next: Symmetric Matrices Up: 1997 UMCP High School Programming Contest

Detecting Palindromes

A palindrome is a word, phrase, or sentence that reads the same backwards and forwards. For example, the word ``radar'' is a palindrome. For this problem, you must write a program that reads a string of characters and prints whether or not the entire string is a palindrome. Your program should ignore all blanks, numbers, and punctuation, and should be case insensitive (i.e., it should not care if characters are capital letters or small letters). For example "5R3a dAr!" should be considered to be a palindrome.

Input Format

The input will consist of a sequence of lines, each of which should be tested separately. Each line will be no greater than 100 characters long. A blank line signals the end of input.

Output Format

After each line, your program should print on a separate line, either YES (if the input was a palindrome) or NO (otherwise).

Example

Input: Output:
radar
rAd. AR
radiar
Able was I ere I saw Elba!
<blank line>
YES
YES
NO
YES

Test data used in judging

Input Output
b
bb
ab
aabaa
aabbaa
aab2aa
aabaaa
Aa BAa
This is a palindrome
radar is a palindrome
A man, a plan, a canal, Panama!
Able was I, ere I saw Panama...
Able was I, ere I saw Elba.
A bell was eye, ear I saw elbow
Go hang a salami, Bub, I'm a Lasagna hog!!!!

Better not check this one!

YES
YES
NO
YES
YES
YES
NO
YES
NO
NO
YES
NO
YES
NO
YES

Our solution



next up previous
Next: Symmetric Matrices Up: 1997 UMCP High School Programming Contest
Bill Pugh
Mon Mar 17 14:34:34 EST 1997