Word wheel: Difference between revisions

Content added Content deleted
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 sorted lowercased words of 3 to 9 characters"
"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 sorted(set(w for w in words if 2 < len(w) < 10))
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 [word for word in dictionary
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))