day1/exercise/anagrams.py
author Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
Mon, 14 Jun 2010 20:16:05 -0400
branchscipy2010
changeset 399 7775af81b51a
parent 395 e886e37a5032
permissions -rw-r--r--
Initial checkin of file with details of the plan for the tutorial.

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]