day1/exercise/anagrams.py
author Christopher Burns <chris.d.burns@gmail.com>
Sun, 20 Jun 2010 22:50:03 -0700
branchscipy2010
changeset 414 68ef3dced7a0
parent 395 e886e37a5032
permissions -rw-r--r--
Add whitespace to assignment.

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]