Word wheel: Difference between revisions
Content added Content deleted
(→{{header|Python}}: optimised.) |
|||
Line 219: | Line 219: | ||
def getwords(url='http://wiki.puzzlers.org/pub/wordlists/unixdict.txt'): |
def getwords(url='http://wiki.puzzlers.org/pub/wordlists/unixdict.txt'): |
||
"Return |
"Return lowercased words of 3 to 9 characters" |
||
words = urllib.request.urlopen(url).read().decode().strip().lower().split() |
words = urllib.request.urlopen(url).read().decode().strip().lower().split() |
||
return |
return (w for w in words if 2 < len(w) < 10) |
||
def solve(grid, dictionary): |
def solve(grid, dictionary): |
||
gridcount = Counter(grid) |
gridcount = Counter(grid) |
||
mid = grid[4] |
mid = grid[4] |
||
return |
return sorted(word for word in dictionary |
||
if mid in word and not (Counter(word) - gridcount) |
if mid in word and not (Counter(word) - gridcount)) |
||