RosettaCodeData/Task/Anagrams/Python/anagrams-2.py
Ingy döt Net 1e05ecd7ee First commit of partial RosettaCode contents.
Pushing this for testing purposes. Lots of work still needed.
2013-04-08 13:02:41 -07:00

14 lines
461 B
Python

import urllib.request, itertools
import time
words = urllib.request.urlopen('http://www.puzzlers.org/pub/wordlists/unixdict.txt').read().split()
print('Words ready')
t0 = time.clock()
anagrams = [list(g) for k,g in itertools.groupby(sorted(words, key=sorted), key=sorted)]
anagrams.sort(key=len, reverse=True)
count = len(anagrams[0])
for ana in anagrams:
if len(ana) < count:
break
print(ana)
t0 -= time.clock()
print('Finished in %f s' % -t0)