#K56062. Anagram Checker
Anagram Checker
Anagram Checker
You are given two strings. Your task is to determine if they are anagrams of each other.
Two strings are anagrams if they use the same letters in the same frequency, ignoring any spaces, punctuation, and capitalization. In other words, after removing any characters that are not letters and converting all letters to lowercase, the two strings should have the same sorted sequence of characters.
Note: All non-alphabet characters should be ignored. The comparison is case-insensitive.
For example, the strings listen
and silent
are anagrams, and so are Dormitory
and Dirty room!
.
Mathematical notations:
Let \( S_1 \) and \( S_2 \) be the processed forms of the input strings. Then the strings are anagrams if:
\[
\text{sorted}(S_1) = \text{sorted}(S_2)
\]
inputFormat
The input is provided via stdin
and consists of two lines:
- The first line contains the first string.
- The second line contains the second string.
Each string may include letters, spaces, punctuation, and other characters.
outputFormat
The output should be printed to stdout
as a single line containing either True
or False
, indicating whether the two strings are anagrams.
listen
silent
True