day1/exercise/anagrams.py
author Christopher Burns <chris.d.burns@gmail.com>
Mon, 28 Jun 2010 23:52:44 -0500
branchscipy2010
changeset 430 f97ecb4e04a9
parent 395 e886e37a5032
permissions -rw-r--r--
REF: Minor format changes to exercise

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]