#C12353. Check if a String is a Palindrome
Check if a String is a Palindrome
Check if a String is a Palindrome
You are given a string s. Your task is to check whether the string is a palindrome, ignoring case, spaces, and punctuation.
A string is a palindrome if it reads the same backward as forward after removing all characters except letters and digits. Mathematically, if we let \(f(s)\) be the function that removes non-alphanumeric characters from \(s\) and converts it to lowercase, then a string is a palindrome if:
\[ f(s) = \text{reverse}(f(s)) \]
Your program should read the input from stdin
and output the result to stdout
as True
if the string is a palindrome; otherwise, output False
.
inputFormat
The input consists of a single string that may include spaces, punctuation, and various characters. The input is read from stdin
.
outputFormat
Output a single line: True
if the string is a palindrome, or False
otherwise. The output is written to stdout
.
A man, a plan, a canal, Panama!
True