#C137. Anagram Checker
Anagram Checker
Anagram Checker
You are given two strings. Your task is to determine whether these two strings are anagrams of each other. Two strings are anagrams if one can be rearranged to form the other by using all the original letters exactly once. The comparison should be made by ignoring any spaces, punctuation, and differences in capitalization.
For example, "Listen" and "Silent" are anagrams, as are "Dormitory" and "Dirty room". However, "Hello" and "World" are not anagrams.
Note: The input consists of two lines, each representing a string, and the output is either True
or False
based on whether the strings are anagrams.
The relation is mathematically expressed as follows: \[ \text{are_anagrams}(s_1, s_2)=\begin{cases} \text{True}, & \text{if } sorted(\text{filter}(s_1)) = sorted(\text{filter}(s_2)) \\ \text{False}, & \text{otherwise} \end{cases} \]
inputFormat
The input is given via standard input (stdin) and consists of two lines:
- The first line contains the first string.
- The second line contains the second string.
outputFormat
Output a single line via standard output (stdout), which is either True
or False
depending on whether the two strings are anagrams of each other.
Listen
Silent
True