Word wheel: Difference between revisions
Content added Content deleted
m (C - removed inline keyword) |
m (→{{header|Python}}: Added an experimental pre-test. Barely worth it, but left it it anyway :-) |
||
Line 588: | Line 588: | ||
cs = ''.join(grid).lower() |
cs = ''.join(grid).lower() |
||
wheel = sorted(cs) |
wheel = sorted(cs) |
||
wset = set(wheel) |
|||
mid = cs[4] |
mid = cs[4] |
||
return [ |
return [ |
||
w for w in ws |
w for w in ws |
||
if 2 < len(w) and (mid in w) and ( |
if 2 < len(w) and (mid in w) and ( |
||
all(c in wset for c in w) |
|||
) |
) and wheelFit(wheel, w) |
||
] |
] |
||
return go |
return go |
||
Line 599: | Line 600: | ||
# wheelFit :: String -> String -> Bool |
# wheelFit :: String -> String -> Bool |
||
def wheelFit(wheel): |
def wheelFit(wheel, word): |
||
'''True if a given word can be constructed |
'''True if a given word can be constructed |
||
from (single uses of) some subset of |
from (single uses of) some subset of |
||
Line 612: | Line 613: | ||
) |
) |
||
) |
) |
||
return |
return go(wheel, sorted(word)) |
||
Line 619: | Line 620: | ||
def main(): |
def main(): |
||
'''Word wheel matches for a given grid in a copy of |
'''Word wheel matches for a given grid in a copy of |
||
http://wiki.puzzlers.org/pub/wordlists/unixdict.txt |
http://wiki.puzzlers.org/pub/wordlists/unixdict.txt |
||
''' |
''' |
||
print('\n'.join( |
print('\n'.join( |