day1/exercise/anagrams.py
author Nishanth Amuluru <nishanth@fossee.in>
Tue, 14 Dec 2010 23:12:25 +0530
branchscipyin2010
changeset 455 84b7a3f4a15a
parent 395 e886e37a5032
permissions -rw-r--r--
updated the checklist to suit new circulate

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]