First commit of partial RosettaCode contents.
Pushing this for testing purposes. Lots of work still needed.
This commit is contained in:
commit
1e05ecd7ee
781 changed files with 9080 additions and 0 deletions
14
Task/Anagrams/Python/anagrams-2.py
Normal file
14
Task/Anagrams/Python/anagrams-2.py
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
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)
|
||||
Loading…
Add table
Add a link
Reference in a new issue