A short Rust program to suggest words to play in Wordle (hard mode), a fantastic word game.
Example usage:
$ cargo run --release
There are 2315 possible words.
Play the word: raise
For each position 1-5, indicate whether there was:
an exact match [e],
a match but in the wrong position [w],
or no match [n]
For example, if there were an exact match in the first position and no remaining matches, enter 'ennnn'.
newnn
There are 14 possible words.
Possible words: maxim panic tacit valid patio mania magic cavil cabin mafia vapid manic cacti habit
Play the word: panic
For each position 1-5, indicate whether there was:
an exact match [e],
a match but in the wrong position [w],
or no match [n]
For example, if there were an exact match in the first position and no remaining matches, enter 'ennnn'.
eeeee
You win!
It chooses words so as to minimize the expected logarithm of the number of remaining words (see the information-theoretic justification here). This is just a heuristic -- for optimality, we would need to consider the game tree. It typically solves in three or four guesses.
I wrote this because I was wondering which word to start with. It suggests "raise" (and considers the worst starting word to be "mamma").