Hacker News new | ask | show | jobs
by rkimb 1599 days ago
I tried yours out, nice work yourself! Seems we took a similar approach in recalculating the letter distributions based on remaining words - both our algos solved it in 4 turns today.

If I may make two small suggestions as a user, I noticed you have a dictionary with nearly 13k words which often results in invalid suggestions like 'clery' and 'meryl'. In testing I found the Scrabble dictionary to be much more likely to yield valid Wordle words (found here: https://github.com/redbo/scrabble), though the official Wordle answers tend to be an even smaller set of ~2,500 common words.

Second, though the implementation is very clean in code (much more concise than mine!), I found the use of the green/gray/yellow methods to be a bit cumbersome when adding constraints. You could wrap these three in a method like guess(word, reply) where your response encodes the feedback as something like [g]=green, [b]=black, [y]=yellow:

Given: [('arose', 27122), ('aeros', 27122), ('seria', 27095), ('riesa', 27095)]

>>> w.guess('arose', 'bybby')

vs.

>>> w.gray('aos') >>> w.yellow('r', 2) >>> w.yellow('e', 5)

You could even have the guess method trigger a new round of suggestions since the response implies that we've advanced a turn.