#C150. Anagram Checker
Anagram Checker
Anagram Checker
Given two strings, determine if they are anagrams of each other. Two strings are anagrams if the letters of one string can be rearranged to form the other, after ignoring spaces and any non-alphabetic characters, and treating uppercase and lowercase letters as equivalent. More formally, if we let \( S_1 \) and \( S_2 \) be the two input strings and define their cleaned versions as
\( \text{clean}(S) = \text{sort}(\{\text{lowercase}(c) : c \in S \text{ and } c \text{ is alphabetic}\}) \)
then the two strings are anagrams if and only if \( \text{clean}(S_1) = \text{clean}(S_2) \).
Your task is to write a program that reads two lines from standard input and outputs True
if the strings are anagrams, and False
otherwise.
inputFormat
The input consists of exactly two lines. Each line contains a string. The first line is the first string and the second line is the second string to compare.
outputFormat
Output a single line to standard output containing either True
or False
. Output True
if the two strings are anagrams (ignoring spaces, non-alphabetic characters and case), otherwise output False
.
Listen
Silent
True