Ordered words: Difference between revisions
→Python: As a fold: (Slight simplification, dropping dropwhile)
(→{{header|Python}}: Added a version using functools.reduce in place of `for` and `sort`) |
(→Python: As a fold: (Slight simplification, dropping dropwhile)) |
||
Line 3,102:
<lang python>'''The longest ordered words in a list'''
from functools import reduce
import urllib.request
Line 3,112 ⟶ 3,110:
'''The longest ordered words in a given list.
'''
xs▼
Line 3,123 ⟶ 3,116:
def triage(nxs, w):
'''The maximum length seen for an ordered word,
and the
'''
n, xs = nxs
lng = len(w)
return (
(lng, ([w] if n != lng else xs + [w])) if
ordWord(w)
) if lng >= n else nxs
Line 3,151 ⟶ 3,144:
if __name__ == '__main__':▼
print(
'\n'.join(longestOrds(
Line 3,160 ⟶ 3,152:
).read().decode("utf-8").split()
))
)</lang>
▲# MAIN ---
▲if __name__ == '__main__':
{{Out}}
<pre>abbott
|