day1/exercise/anagrams.py
author Puneeth Chaganti <punchagan@fossee.in>
Thu, 09 Dec 2010 23:11:12 +0530
branchscipyin2010
changeset 448 dc8d666a594a
parent 395 e886e37a5032
permissions -rw-r--r--
Changed date format in day1/session{3,4,5}.tex.

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]