A word is an anagram if the letters in that word can be re-arranged to form a different word.
The shortest source code by character count to find
import sys; words=sys.stdin.readlines() def s(x):return sorted(x.lower()); print '\n'.join([''.join([a.replace('\n',' ') for a in words if(s(a)==s(w))]) for w in words])