day1/exercise/anagrams.py
author Puneeth Chaganti <punchagan@gmail.com>
Sat, 01 May 2010 16:16:39 +0530
changeset 395 e886e37a5032
permissions -rw-r--r--
Added program anagrams.py.

anag = {}
for line in open( 'anag.txt'):
	word = line.strip()
	key = ''.join(sorted(list(word)))
	if key not in anag:
		anag[ key ] = [ word ]
	else:
		anag[key].append(word)
for key in anag:
	if len(anag[key]) > 1:
		print anag[key]