summaryrefslogtreecommitdiff
path: root/day1/exercise/anagrams.py
blob: 28a5b0fda6bc9cad538e515563e8317deb283669 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
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]