Canadian Computing Competition: 2007 Stage 1, Junior #4
An anagram is a word or a phrase formed by rearranging the letters of another phrase such as ITEM
and TIME
. Anagrams may be several words long such as CS AT WATERLOO
and COOL AS WET ART
. Note that two phrases may be anagrams of each other even if each phrase has a different number of words (as in the previous example). Write a program to determine if two phrases are anagrams of each other.
Input Specification
The program should take two phrases, each on a separate line. You may assume that the input only contains uppercase letters and spaces.
Output Specification
The program will print out one of two statements: Is an anagram.
or Is not an anagram.
Sample Input
CS AT WATERLOO
COOL AS WET ART
Sample Output
Is an anagram.
Comments
Fun fact: you can do this in one line in python. Give it a try.
Mission accomplished: https://dmoj.ca/submission/6713521
https://dmoj.ca/submission/6556383
if ur getting it wrong try aabbcc and aabccc
This comment is hidden due to too much negative feedback. Show it anyway.
no offense but how does one come to such a conclusion? the task here is just to check if the characters used/amount of each in both phrases are the same
Why do I get test 6 wrong(WA)?
Check what
.replace
does. (Hint: the original string remains unmodified.)u weeb
based reply