Sane's Monthly Algorithms Challenge: October 2008

Eliminanagram (Beginner Level)

An anagram is a word whose letters can be rearranged to form a different word. For example, "rat" is an anagram of "tar" and "meat" is an anagram of "tame".

An eliminanagram is much like an anagram, only many more exist. This is because in an eliminanagram, we eliminate pairs of duplicate letters to see if they are eliminanagrams. If all letters can be eliminated by deleting two identical letters at a time, then we have an eliminanagram.

For example, to check if "mississippi" and "mamma" are eliminanagrams, we can do the following:

mississippi mamma
mississippi mamma
mississippi mamma
mississippi mamma
mississippi mamma
mississippi mamma
mississippi mamma
mississippi mamma
mississippi mamma (None left over = Yes)

It can be proven that all anagrams are also eliminanagrams (but not necessarily the other way around).

meat tame
meat tame
meat tame
meat tame (None left over = Yes)

But even if they have the same letters, they are not necessarily eliminanagrams:

lot toll
lot toll
lot toll (1 letter left over = No)

Your task is to determine whether or not two given words are eliminanagrams.

Input

On the first line is the first word.
On the second line is a the second word.
Each word contains only lower-case letters ('a' – 'z') and will not exceed 40 characters in length.

Output

Output "Yes" if the two words are eliminanagrams. Otherwise, output "No".

Sample Input #1

eliminanagram
lager

Sample Output #1

Yes

Sample Input #2

rate
tear

Sample Output #2

Yes

Sample Input #3

lass
sail

Sample Output #3

No

All Submissions
Best Solutions


Point Value: 5
Time Limit: 2.00s
Memory Limit: 16M
Added: Nov 03, 2008
Author: DrSane

Languages Allowed:
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3

Comments (Search)

So when you do this, does the first word get all eliminated then the second word, or all of them at once?

The problem just says that you eliminate pairs of equal letters until all of the letters (from both words) are gone, or until you can't anymore.