#C13789. Palindrome Word Extraction
Palindrome Word Extraction
Palindrome Word Extraction
Given a string of text, extract all the words that are palindromic. A word is defined as a contiguous sequence of alphabetic characters (i.e. [a-zA-Z]
), and comparisons should be done in a case-insensitive manner. Formally, a word \(w\) is a palindrome if \(w = w^{R}\), where \(w^{R}\) denotes the reverse of the word.
Your task is to read the input from standard input (stdin), identify each word, check if it is a palindrome and then print all palindromic words in the order they appear, separated by a single space, to standard output (stdout). If there are no palindromic words, output an empty line.
inputFormat
The input consists of a single line of text which may include letters, spaces, punctuation, and numbers. Only alphabetic characters are used to form words.
outputFormat
Output a single line containing the palindromic words found in the input, separated by a single space. If no palindromes are found, output an empty line.
## sampleMadam Arora teaches malayalam
madam arora malayalam