summaryrefslogtreecommitdiff
path: root/day1/exercise/anagrams.py
diff options
context:
space:
mode:
Diffstat (limited to 'day1/exercise/anagrams.py')
-rw-r--r--day1/exercise/anagrams.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/day1/exercise/anagrams.py b/day1/exercise/anagrams.py
new file mode 100644
index 0000000..28a5b0f
--- /dev/null
+++ b/day1/exercise/anagrams.py
@@ -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