day1/exercise/anagrams.py
changeset 395 e886e37a5032
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/day1/exercise/anagrams.py	Sat May 01 16:16:39 2010 +0530
@@ -0,0 +1,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]
+         
\ No newline at end of file