SMAC 08/09 (Oct) #1 - Eliminanagram

View as PDF

Submit solution

Points: 5
Time limit: 1.0s
Memory limit: 16M

Problem type
Sane's Monthly Algorithms Challenge: October 2008

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 Specification

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

Output Specification

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

Comments

There are no comments at the moment.