diff --git a/play_solve.py b/play_solve.py index 97d9594..693d042 100644 --- a/play_solve.py +++ b/play_solve.py @@ -76,6 +76,8 @@ def main(): # [('flute', [2]), ('ulnae', [2]), ('neath', [2]), ('guile', [2]), ('brave', [2]), ('bulge', [2]), ('lunge', [2]), ('avoid', [2]), ('suing', [2]), ('cased', [2]), ('flesh', [2]), ('boned', [2]), ('query', [2]), ('squat', [2]), ('gazer', [2]), ('crest', [2]), ('moray', [2]), ('nodal', [2]), ('stain', [2]), ('snort', [2]), ('satyr', [2]), ('stage', [2]), ('often', [2]), ('snark', [2]), ('laugh', [2]), ('relay', [2]), ('flown', [2]), ('aping', [2]), ('pious', [2]), ('islet', [2]), ('whorl', [3, 2]), ('bitch', [2, 3]), ('mused', [3, 2, 4]), ('scary', [4, 2]), ('teary', [2, 4]), ('parse', [4, 2, 4]), ('manse', [2, 6]), ('robed', [3]), ('aisle', [3]), ('stare', [3]), ('angry', [3]), ('nixed', [3]), ('clang', [3]), ('avert', [3]), ('wager', [3]), ('bushy', [3]), ('gayer', [3]), ('vouch', [3]), ('spite', [3]), ('fazes', [3]), ('buxom', [3]), ('hound', [3]), ('enrol', [3]), ('pearl', [3]), ('ultra', [3]), ('whine', [3]), ('leach', [3]), ('sheaf', [3]), ('clove', [3]), ('smoke', [3]), ('scant', [3]), ('gamer', [3]), ('after', [3]), ('first', [3]), ('tenor', [3]), ('adult', [3]), ('vowed', [3]), ('gnarl', [3]), ('begin', [3]), ('umiak', [3]), ('spore', [3]), ('strap', [3]), ('right', [3]), ('vista', [3]), ('unbar', [3]), ('dowse', [3]), ('intro', [3]), ('hefty', [3]), ('lover', [3]), ('wormy', [3]), ('fails', [3]), ('vicar', [3]), ('torus', [3]), ('civet', [3]), ('lured', [3]), ('flint', [3]), ('shaft', [3]), ('whelp', [3]), ('oldie', [3]), ('blimp', [3]), ('locus', [3]), ('poxes', [3]), ('flame', [3]), ('beryl', [3]), ('dance', [3]), ('store', [3]), ('pried', [3]), ('awoke', [3]), ('copes', [3]), ('overt', [3... + # sorted([(k, sum(w)/len(w), stdev(w)/sqrt(len(w))) for k, w in filter(lambda x: len(x[1]) > 100, guess_words_d.items())], key=lambda x: x[1]) + # [('scorn', 4.1075949367088604, 0.0825818185526351), ('miter', 4.141891891891892, 0.09492070753231313), ('nacre', 4.1440677966101696, 0.07537640788338928), ('slant', 4.147826086956521, 0.034208818102404275), ('plush', 4.148760330578512, 0.10342692621738281), ('slope', 4.148760330578512, 0.04349886654069182), ('drips', 4.149038461538462, 0.07502938351884941), ('triad', 4.14935064935065, 0.09249141329893873), ('tired', 4.149390243902439, 0.0657503890009043), ('treas', 4.149565217391304, 0.03383034452529548), ('rains', 4.149732620320855, 0.06067763162826029), ('emits', 4.15, 0.059885221930429354), ('prate', 4.15, 0.06969249052591192), ('scant', 4.150125628140704, 0.02813607805882363), ('wades', 4.150234741784038, 0.08381151954987603), ('waver', 4.150326797385621, 0.0863844146779315), ('gloat', 4.150354609929078, 0.04239520424885032), ('orate', 4.150442477876106, 0.07717797380823617), ('price', 4.150485436893204, 0.07729976331699613), ('slate', 4.150537634408602, 0.06159265252476201), ('bloat', 4.1506849315068495, 0.08657797332811965), ('spelt', 4.150918635170604, 0.03951928045885527), ('enact', 4.150943396226415, 0.11118285274253947), ('miler', 4.151260504201681, 0.12324174639015424), ('drain', 4.15136476426799, 0.05835958744274579), ('septa', 4.151515151515151, 0.05121569873852983), ('adopt', 4.151515151515151, 0.09527639066519798), ('scrub', 4.151785714285714, 0.10551843988830854), ('flays', 4.151785714285714, 0.11288442215476054), ('pored', 4.152380952380953, 0.1072303265261948), ('saber', 4.15242494226328, 0.05653832854421806), ('penis', 4.152671755725191, 0.10193275070172132), ('glade', 4.153061224489796, 0.0565884877459108), ('gland', 4.153846153846154, 0.11331223325334346), ('beast', 4.154302670623146, 0.06289887984565301), ('prone', 4.154545454545454, 0.07496303981304892), ('hotel', 4.15483870967742, 0.08786531161762064), ('stung', 4.15527950310559, 0.09095721394121946), ('bidet', 4.155405405405405, 0.09764313880359478), ('greps', 4.155405405405405, 0.059664982328452895), ('tapir', 4.155913978494624, 0.08394489249492998), ('yacht', 4.155963302752293, 0.11225782778579602), ('routs', 4.15609756097561, 0.07900094709866701), ('swear', 4.1567567567567565, 0.07712025611264886), ('shunt', 4.15680473372781, 0.06033761505535241), ('flirt', 4.156976744186046, 0.09233540568070339), ('plays', 4.157894736842105, 0.06976032398574289), ('tings', 4.157894736842105, 0.08713946650128217), ('salty', 4.158536585365853, 0.09551479097394311), ('plant', 4.159420289855072, 0.07713916627780328), ('octal', 4.159663865546219, 0.09694316138114932), ('manly', 4.159763313609467, 0.08614305076361524), ('halts', 4.159836065573771, 0.0751402917168549), ('tenor', 4.16, 0.09604249618697706), ('bread', 4.16, 0.11094898566167624), ('slier', 4.160377358490566, 0.07602575398484725), ('splat', 4.160714285714286, 0.10269343381888044), ('shlep', 4.160839160839161, 0.0918475078869739), ('torsi', 4.160919540229885, 0.09176696807271827), ('franc', 4.161111111111111, 0.07924374426348677), ('pride', 4.161290322580645, 0.11125202212891487), ('rated', 4.161417322834645, 0.07632736981555216), ('shawl', 4.161538461538462, 0.09381838743853903), ('topic', 4.162790697674419, 0.09128092132620687), ('laths', 4.162790697674419, 0.10771515880028433), ('stale', 4.163090128755365, 0.07545954313636921), ('bates', 4.163461538461538, 0.08463892362022453), ('oaten', 4.163793103448276, 0.06522064926634694), ('plies', 4.164021164021164, 0.084866899503943), ('daily', 4.165048543689321, 0.11469016305070763), ('alien', 4.165354330708661, 0.10592011167473217), ('spate', 4.165605095541402, 0.08613080124955529), ('argot', 4.1657142857142855, 0.08188948572552117), ('sprat', 4.166270783847981, 0.05244616034498429), ('edits', 4.166666666666667, 0.08392928848249637), ('stage', 4.166666666666667, 0.09758454908811537), ('spore', 4.166666666666667, 0.08430563846754494), ('loads', 4.166666666666667, 0.11478067422089476), ('fount', 4.1688311688311686, 0.09295952408533989), ('slain', 4.169811320754717, 0.10679661175663192), ('soled', 4.17037037037037, 0.09949609954311861), ('untie', 4.1716417910447765, 0.09910729323364766), ('sylph', 4.171779141104294, 0.09069195987291062), ('cloys', 4.172043010752688, 0.08931503752016207), ('tidal', 4.172413793103448, 0.0934719787152404), ('trend', 4.1725146198830405, 0.06487413906736084), ('spiny', 4.173184357541899, 0.0767389954342389), ('cadge', 4.173410404624278, 0.08730357667344175), ('teach', 4.173501577287066, 0.06975818418768448), ('loped', 4.174311926605505, 0.10083244807763622), ('scalp', 4.174311926605505, 0.10332892422381902), ('podia', 4.174311926605505, 0.10576649080485871), ('tries', 4.174825174825175, 0.1003856865037523), ('carol', 4.175141242937853, 0.09128192736171828), ('chore', 4.175438596491228, 0.07394339790929716), ('bodes', 4.175925925925926, 0.1153115962382661), ('trike', 4.176470588235294, 0.10717531785392602), ('penal', 4.176954732510288, 0.0711136633999781), ('align', 4.177570093457944, 0.11788792883559858), ('begot', 4.177570093457944, 0.12011066145398014... if __name__ == "__main__": diff --git a/solve.py b/solve.py index 09eddc4..69c4d6f 100644 --- a/solve.py +++ b/solve.py @@ -5,8 +5,9 @@ from lib import cat_words, INSTRUCTIONS, BLANK, ROUNDS, DEBUG, DICTIONARY def remove_non_letters(word, non_letters, unconsumed_letters, non_pos_unconsumed_letters): for non_letter in non_letters: - if non_letter in word and non_letter in unconsumed_letters and non_letter in non_pos_unconsumed_letters: - return True + if non_letter in word: + if non_letter in unconsumed_letters or non_letter in non_pos_unconsumed_letters: + return True return False @@ -23,17 +24,19 @@ def remove_positional_letters(word, positional_letters): return rv, unconsumed_letters -def remove_non_positional_letters(word, non_positional_letters): - rv, unconsumed_letters = False, '' +def remove_non_positional_letters(word, non_positional_letters, unconsumed_letters): + rv, non_pos_unconsumed_letters = False, '' for non_pos_idx, non_positional_letter in enumerate(non_positional_letters): if non_positional_letter == BLANK: continue - unconsumed_letters += word[non_pos_idx] + non_pos_unconsumed_letters += word[non_pos_idx] + if non_positional_letter in unconsumed_letters: + unconsumed_letters = unconsumed_letters.replace(non_positional_letter, '', 1) if non_positional_letter not in word: rv = True elif word[non_pos_idx] == non_positional_letter: rv = True - return rv, unconsumed_letters + return rv, non_pos_unconsumed_letters, unconsumed_letters def round_words(non_letters, all_positional_letters, all_non_positional_letters, dictionary=DICTIONARY): @@ -48,7 +51,8 @@ def round_words(non_letters, all_positional_letters, all_non_positional_letters, continue # Find non-positional letters, e.g. h-s-- for non_positional_letters in all_non_positional_letters: - skip, non_pos_unconsumed_letters = remove_non_positional_letters(word, non_positional_letters) + skip, non_pos_unconsumed_letters, unconsumed_letters = remove_non_positional_letters( + word, non_positional_letters, unconsumed_letters) if skip: break if skip: @@ -157,6 +161,7 @@ def do_test(): assert [w for w in round_words('', ['towns'], ['-----'], dictionary=['towns'])] == ['towns'] assert [w for w in round_words('', ['-----'], ['stown'], dictionary=['towns'])] == ['towns'] assert [w for w in round_words('', ['----y'], ['-----'], dictionary=['slily'])] == ['slily'] + assert [w for w in round_words('', ['-----'], ['yy---'], dictionary=['slyly'])] == ['slyly'] assert [w for w in round_words('', ['----y'], ['y----'], dictionary=['slyly'])] == ['slyly'] assert [w for w in round_words('', ['---yy'], ['y----'], dictionary=['slyyy'])] == ['slyyy'] assert [w for w in round_words('', ['---yy'], ['-----'], dictionary=['slyyy'])] == ['slyyy'] @@ -164,6 +169,7 @@ def do_test(): assert [w for w in round_words('', ['--b-y'], ['ab---'], dictionary=['cabby'])] == ['cabby'] assert [w for w in round_words('', ['--b-y'], ['-a-b-'], dictionary=['abbey'])] == ['abbey'] assert [w for w in round_words('nu', ['-o-ns'], ['-----'], dictionary=['towns'])] == ['towns'] # nouns + assert [w for w in round_words('r', ['p-int'], ['-----'], dictionary=['print', 'point'])] == ['point'] assert [w for w in round_words('fos', ['-l---'], ['---s-'], dictionary=['slung'])] == ['slung'] # typed basil floss