new files
This commit is contained in:
parent
3af7344581
commit
86c034bb8b
1364 changed files with 21352 additions and 0 deletions
8
Task/Ordered-words/Python/ordered-words-1.py
Normal file
8
Task/Ordered-words/Python/ordered-words-1.py
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import urllib.request
|
||||
|
||||
url = 'http://www.puzzlers.org/pub/wordlists/unixdict.txt'
|
||||
words = urllib.request.urlopen(url).read().decode("utf-8").split()
|
||||
ordered = [word for word in words if word==''.join(sorted(word))]
|
||||
maxlen = len(max(ordered, key=len))
|
||||
maxorderedwords = [word for word in ordered if len(word) == maxlen]
|
||||
print(' '.join(maxorderedwords))
|
||||
11
Task/Ordered-words/Python/ordered-words-2.py
Normal file
11
Task/Ordered-words/Python/ordered-words-2.py
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
import urllib.request
|
||||
|
||||
mx, url = 0, 'http://www.puzzlers.org/pub/wordlists/unixdict.txt'
|
||||
|
||||
for word in urllib.request.urlopen(url).read().decode("utf-8").split():
|
||||
lenword = len(word)
|
||||
if lenword >= mx and word==''.join(sorted(word)):
|
||||
if lenword > mx:
|
||||
words, mx = [], lenword
|
||||
words.append(word)
|
||||
print(' '.join(words))
|
||||
3
Task/Ordered-words/Python/ordered-words-3.py
Normal file
3
Task/Ordered-words/Python/ordered-words-3.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
from itertools import groupby
|
||||
o = (w for w in map(str.strip, open("unixdict.txt")) if sorted(w)==list(w))
|
||||
print list(next(groupby(sorted(o, key=len, reverse=True), key=len))[1])
|
||||
Loading…
Add table
Add a link
Reference in a new issue