Home‎ > ‎ProgComp‎ > ‎ProgComp 2016 Open Tasks‎ > ‎

Task J. Palindromes

Task J. Palindromes

Available Marks: 7

palindrome is a word or sentence that reads the same when written backwards, ignoring punctuation and treating capital letters and small letters as the same. So

radar
taco cat
Cigar? Toss it in a can. It is so tragic!
are all palindromes.

Your task

Write a program that determines whether phrases are palindromes or not. The first line of input contains the number of phrases (up to 20). The remaining lines have one phrase each. Each phrase has up to 70 characters. Your output is either Yes or No, followed by the phrase enclosed in quote characters.

Example

5
rotor
gnu dung
O Geronimo, no major ego.
Ten animals we slam in a net.
Harpo: not on Oprah?
produces...
Yes "rotor"
Yes "gnu dung"
 No "O Geronimo, no major ego."
 No "Ten animals we slam in a net."
Yes "Harpo: not on Oprah?"

Test data

Test your program using the following input text.

20
racecar
racing car
Tumut
a
stressed was I ere I saw desserts
Straw? No, too stupid a fad; I put soot on warts
Was it a car or a cab I saw?
Ed, I saw Harpo Marx ram Oprah W. aside.
Yes, Mel Gibson is a casino's big lemon.
Mr Owl ate my metallic worm.
Go hang a salami, I'm a lasagna hog!
On a clover, if alive, erupts a vast, pure evil; a fire volcano.
Dennis, Nell, Edna, Leo, Noel and Ellen sinned.
A man, a plan, a cat, a ham, a yak, a yam, a bat, a canal--Panama!
Steven, I left an oily lion at feline vets.
Put Eliot's toilet up.
Marg, let's send a sadness telegram!
Yawn....Madonna fan? No damn way!!
Red rum, sir, is murder!
'Reviled did I live,' said I, 'as evil I did deliver.'
Comments