new files
This commit is contained in:
parent
3af7344581
commit
86c034bb8b
1364 changed files with 21352 additions and 0 deletions
12
Task/Anagrams/Python/anagrams-1.py
Normal file
12
Task/Anagrams/Python/anagrams-1.py
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
>>> import urllib.request
|
||||
>>> from collections import defaultdict
|
||||
>>> words = urllib.request.urlopen('http://www.puzzlers.org/pub/wordlists/unixdict.txt').read().split()
|
||||
>>> anagram = defaultdict(list) # map sorted chars to anagrams
|
||||
>>> for word in words:
|
||||
anagram[tuple(sorted(word))].append( word )
|
||||
|
||||
|
||||
>>> count = max(len(ana) for ana in anagram.values())
|
||||
>>> for ana in anagram.values():
|
||||
if len(ana) >= count:
|
||||
print ([x.decode() for x in ana])
|
||||
Loading…
Add table
Add a link
Reference in a new issue