This simple script solves the wordle game by filtering the dictionary and picking the word that maximises the information gained from each word guess.
The solver is optimal for shallow search (averaging 3.46 words per solve), and guarentees to solve the game within 6 words.
-
Open chrome dev tools (Ctrl + Shift + I) and paste
index.jsinto chrome Content snippets. -
Press (Ctrl + Enter) to run the snippet.
For each round, the solver filters out all the possible moves that can result in the given Green, Yellow, Black combination. It then pickes the word that divides the remaining words (by calculating the array of colours) so that entropy is maximised.
When using the results dictionary exclusively, the best starting word is RAISE. The solver averages 3.600 words per solve, with the maximum being 8 words for BOXER.
When using the extended dictionary, the best starting word is according to the algorithm is SOARE. The solver averages 3.464 words per solve, with the maximum being 6 words for WAFER.
To improve runtime and the number of average guesses, the best result from a deep search SALET is used as the starting word (reducing the average down to 3.4328). This behaviour can be disabled by passing useCache=false to highestGainWord().