Anagrams |
An anagram is a word or phrase formed by rearranging the letters of another word or phrase. For example, ``carthorse" is an anagram of ``orchestra". Blanks within a phrase are ignored in forming anagrams. Thus, ``orchestra" and ``horse cart" are also anagrams.
Write a program that reads a list of phrases and prints all pairs of anagrams occurring in the list.
Input will consist of from 1 to 100 lines. A completely empty or blank line signals the end of input. Each line constitutes one phrase.
Some number of lines (including possibly 0 if there are no anagrams in the list), each line containing two anagrammatic phrases separated by `='.
Each anagram pair should be printed exactly once, and the order of the two phrases within a printed pair must be lexicographic, as well as the first phrases and the second ones in case some first are equal.
carthorse horse horse cart i do not know u ok i now donut orchestra
carthorse = horse cart carthorse = orchestra horse cart = orchestra i do not know u = ok i now donut