#C14770. String Analysis: Palindrome and Vowel Count
String Analysis: Palindrome and Vowel Count
String Analysis: Palindrome and Vowel Count
Given a string, your task is to perform two operations:
- Determine if the string is a palindrome, ignoring spaces, punctuation, and case. To do this, consider only alphanumeric characters. For instance, the string
A man, a plan, a canal, Panama
is a palindrome. - Count the number of vowels in the original string. The vowels are a, e, i, o, u (both lowercase and uppercase).
Output your answer on two separate lines: the first line should output true
if the string is a palindrome or false
otherwise; the second line should output an integer representing the total vowel count.
In mathematical terms, for the palindrome check, define the filtering process as follows: $$ \text{filtered}(s) = \text{lowercase}(\text{RemoveNonAlnum}(s)) $$ Then, a string is a palindrome if and only if $$ \text{filtered}(s) = \text{reverse}(\text{filtered}(s)). $$
inputFormat
The input consists of a single line containing the string to be analyzed. The string may include letters, digits, spaces, and punctuation.
outputFormat
The output should be printed in two lines:
- The first line prints
true
if the string is a palindrome (ignoring spaces, punctuation, and case) orfalse
otherwise. - The second line prints an integer representing the total number of vowels in the input string.
A man, a plan, a canal, Panama
true
10
</p>