Andy loves anagrams. For the uninitiated, an anagram is a word formed by rearranging the letters of another word, for example rasp can be rearranged to form spar. Andy is interested to know if two words are almost anagrams. A word is almost an anagram of another word if:
one word is shorter than the other by one letter but otherwise contains the same letters in any order; or
the two words are the same length and their character multisets differ by one character only e.g. “aaa” and “aab”
Your job is to help Andy to determine if two words are identical, anagrams, almost anagrams or nothing like each other.
The input contains a single test case.
The input will be a single line of text containing a pair of words separated by a single space. The words will be in lower case and will contain alphabetic characters only. Words will contain between 1 and 1000 letters inclusive.
Your program should produce one line of output as follows:
If the words are identical, output: worda is identical to wordb
If the words are anagrams, output: worda is an anagram of wordb
If the words are almost anagrams, output: worda is almost an anagram of wordb
Otherwise, output: worda is nothing like wordb
In all cases the first word in the output sentence must be the shorter word or if the words are the same length the first word must be the lexicographically least.
rasp is an anagram of spar
SourceACM South Pacific Western Division > ACM South Pacific Western Division 2015 J, ACM South Pacific E