#C161. Anagram Checker
Anagram Checker
Anagram Checker
Given two strings, determine whether they are anagrams of each other. Two strings \(s_1\) and \(s_2\) are anagrams if, after removing all non-alphabetic characters and converting all letters to lowercase, their characters in sorted order are identical. Formally, if we define the cleaning function as \(f(s)=\text{sort}(\{\text{tolower}(c)\mid c\in s \text{ and } \text{isalpha}(c)\})\), then \(s_1\) and \(s_2\) are anagrams if and only if \(f(s_1)=f(s_2)\).
inputFormat
The input consists of two lines read from stdin. The first line contains the string \(s_1\) and the second line contains the string \(s_2\). These strings may include spaces, punctuation, and other non-alphabetic characters.
outputFormat
Output a single line to stdout containing either True
if the two strings are anagrams or False
otherwise.
Listen
Silent
True