#C9664. Palindrome Checker
Palindrome Checker
Palindrome Checker
Given a string s, determine whether it is a palindrome. A string is considered a palindrome if, after removing all non-alphanumeric characters and converting all letters to lowercase, it reads the same forwards and backwards.
Mathematically, let \( f(s) \) be the filtered version of \( s \) where
\[ f(s) = \text{lowercase}(\{ c \in s \mid c \text{ is alphanumeric} \}) \]
The string \( s \) is a palindrome if and only if
\[ f(s) = \text{reverse}(f(s)) \].
Your task is to implement this functionality. The input is read from standard input (stdin) and the result should be printed to standard output (stdout) as either True
or False
.
inputFormat
The input consists of a single line containing the string s. This string may include spaces, punctuation, and mixed case letters.
outputFormat
Output a single line: True
if the filtered string is a palindrome, and False
otherwise.
A man, a plan, a canal, Panama
True