Ordered words: Difference between revisions

Content added Content deleted
m (→‎{{header|Python}}: Sectioning)
Line 3,071: Line 3,071:


=={{header|Python}}==
=={{header|Python}}==
===Python: First Solution===
<lang python>import urllib.request
<lang python>import urllib.request


Line 3,080: Line 3,081:
print(' '.join(maxorderedwords))</lang>
print(' '.join(maxorderedwords))</lang>


'''Alternate Solution'''
===Python: Alternate Solution using one explicit loop===
<lang python>import urllib.request
<lang python>import urllib.request


Line 3,095: Line 3,096:
'''Sample Output'''
'''Sample Output'''
<pre>abbott accent accept access accost almost bellow billow biopsy chilly choosy choppy effort floppy glossy knotty</pre>
<pre>abbott accent accept access accost almost bellow billow biopsy chilly choosy choppy effort floppy glossy knotty</pre>

Short local version:
===Python: Short version===
<lang python>from itertools import groupby
<lang python>from itertools import groupby
o = (w for w in map(str.strip, open("unixdict.txt")) if sorted(w)==list(w))
o = (w for w in map(str.strip, open("unixdict.txt")) if sorted(w)==list(w))