Several months back I wrote a short explainer on my initial script that played Wordle using a list of common English words. Well, nearly 200 days and one tragically lost streak later, I have returned with a new and improved method of guessing five letter words in six attempts. Please journey with me as I explain my code to whittle down the huge word list in a few short guesses. Or, for the impatient types, feel free to skip to the end where I tell you exactly how to do it yourself.
The Word List
Initially I used a word frequency list from Project Gutenberg (PG) and eliminated any words that were not five letters long or had either capital letters or special characters. There were a few problems with this: one – the list trended towards older words as PG pulls from mainly public domain books, and two – my filters didn’t catch all proper nouns and acronyms since many were listed in all lowercase letters. My updated code would not incorporate frequency in English, so I mulled over swapping out the list for a Scrabble dictionary before learning that the entire accepted word list is buried in a JavaScript file on the Wordle webpage.
The actual Wordle word list is split into two parts: the answer list in order by day, and the rest of the words that are accepted inputs but will not be the correct answer. The game checks your machine’s clock and indexes to the answer word based on the date. What the New York Times will do in 2027 when it reaches the end of the list is anyone’s guess. They will likely randomize it and start again.
A few words have shuffled around on the answer list since the game moved to the NYT. Originally the list ended with SHAVE, but there are now some words after that that were moved from earlier in the list. Most notable is FETUS, which was originally the answer right after the draft US Supreme Court opinion on the Roe repeal was leaked. Some have uncomfortable connotations like STALK, but others are just uncommon in American English. AUGUR was supposed to be the answer just a few days ago between WEDGE and ROOMY.
Once I found this file, I was glad that I now had access to the full list, but there was one problem: the full accepted word list including the answers is 12,974 words long. This was about three times as large as the list I was using before, and I was having difficulty paring that list down. As a compromise, I kept using my PG list and tacked on any words from the actual answer list that were not on it (there were a few like FOYER).
So, when I say I mostly beat Wordle, I mean I beat Wordle for my Frankenstein list (that includes all the real answers!) that is but a measly 4,100 words long.
The Algorithm
My initial method that I described in my Disqus post relied on either the frequency of the word in English or the frequency of the word’s letters and would make progressive guesses based on the previous guesses and their results. This time, I decided to try something different: have a set four initial guesses and base the fifth guess on the remaining possibilities that adhered to the results from those four guesses.
The check for each letter has the possibility of being green, yellow, or black (I use the dark theme), meaning there are 35 = 243 check possibilities for any given guess. A set four guesses should in theory mean that 2434 = 3,486,784,401 individual words could be determined just from those four guesses since there are 3,486,784,401 unique color combinations of the results. The problem is, of course, that we are not picking square colors but words from the English language. The words will not evenly distribute among the bins and there will be many collisions because of the constraints of English, like needing a vowel for each word. Additionally, there are also square color combinations that are not possible during normal play, like 🟩🟩🟩🟩🟨 (GGGGY) since the last letter cannot be both misplaced and in the only remaining non-determined space. That said, the more the words in the list can be spread among the possible color combinations, the more words can be correctly guessed.
The algorithm essentially groups together words that have the same color square permutation after entering in the first four guesses. For each word in the word list, it finds the check result for an individual guess, and then within that loop, loops through the word list again to find any words that match that check result. This list of remaining possibilities is then intersected with the list from the next guess. After going through all the guesses, hopefully the only remaining possible word is the word from the outside loop. This would mean that the only word that fits a particular permutation of color squares is that word. Put graphically, it looks like this:

As shown, SHARK is the chosen word in the list. The first guess is TEARS, and the resulting squares narrow the list of all five letter words down to SHARD, SHARP, SPARK, SHARK, SNARK, etc. The next guess is DOING, which in isolation narrows all possible words down to SHARP, SPARK, SHARK, LATER, ASKEW, etc. The intersection list of these two guesses is SHARP, SPARK, SHARK. When this list is further intersected with the guess of LUCKY, the list of possibilities is narrowed down to SPARK and SHARK. Since SHARK is not the only word that applies for these three guesses, an additional guess would be necessary to determine whether the answer is SHARK or SPARK.
You may be thinking that double nested loops iterating through a long word list is computationally quite expensive, and it would save much more time to find the color permutation of all guesses for each word and then sort the list to group words together. You would be correct. I was just too lazy to rewrite the code.
The Four Guesses (Part I)
The next task was to choose the four initial guesses that would group together the word list using the algorithm. My strategy for playing Dordle came in handy here: I needed to try as many different letters as possible before determining any answer words. Trying to pinpoint one of the words too early in Dordle can lock you out of finding the other word, so it is better to cast a wide net. I started with my typical Dordle guesses, which are STARE, DOING, LUCKY, WHUMP. Q, F, J, Z, X, V, and B are the only remaining untried letters, and U is the only letter tried twice, each in a different spot in the word.
I sorted through my word list using those guesses and the code grouped together the words. This is the plot of the size of the remaining possibilities list for each word and a histogram of the same data grouped by list length:


There are 3,212 words that can be immediately guessed as a fifth guess since they are the only possible word remaining that fits the square colors. There are also an additional 604 words that can be determined in two guesses since they have a remaining possibility list of two. The challenge is in the lists with three or more words where the fifth guess will need to isolate those lists further. Especially tricky are the two seven-word-long lists that are the result of the initial guesses.
I wanted to see how small changes to the initial guesses would affect the distribution of remaining word lists. I swapped out STARE for TEARS, which is its anagram. Even though I was not changing any of the tried letters, shuffling around letter placement could affect the resulting word lists. Starting with TEARS, DOING, LUCKY, WHUMP, I plotted the new data:


These are more manageable than using STARE as a guess. There are now 3,236 words that can be guessed in one attempt and 608 that can be determined in two. The longest remaining word list is now six words long and there is only one of them.
Are there four guesses that yield even better distributions? Almost certainly, but I decided to stick to these four as I moved on to find the fifth guesses.
The Fifth Guess
This is where the guesses would need to diverge since there is not one set fifth guess that would split up all the remaining word lists. Each list would need to be looked at individually to determine a word that would yield a unique square color combination from each possible answer word in that list.
Many of these word lists were either words that all rhymed or consisted of anagrams and near-anagrams. As an example, let’s look at two of the lists: FINER INFER INNER RIVEN and BATCH CATCH HATCH. The former is a list with near-anagrams and the latter is rhyming words. For many of the near-anagram lists, the fifth guess could be pulled from the list itself. Using INFER as a guess splits the first list like so:
FINER: 🟨🟨🟨🟩🟩 (YYYGG)
INFER: 🟩🟩🟩🟩🟩 (GGGGG)
INNER: 🟩🟩⬛🟩🟩 (GGBGG)
RIVEN: 🟨🟨⬛🟩🟨 (YYBGY)
This guess isolates each remaining word in the possibilities list, eliminating all guesswork for the sixth guess.
For the rhyming lists, it is instead necessary to choose a word that uses many of the differing letters, which in this case are B, C, and H. It is also important to be cognizant of the duplicate letters for these words because a yellow C or H will likely not tell the player any new information. We can use CRIBS as a guess for this list:
BATCH: 🟨⬛⬛🟨⬛ (YBBYB)
CATCH: 🟩⬛⬛⬛⬛ (GBBBB)
HATCH: 🟨⬛⬛⬛⬛ (YBBBB)
Like the previous list, this guess splits up all the words in the list.
So, using my initial four guesses of TEARS DOING LUCKY WHUMP, I was able to narrow down all of my remaining lists – except for one. I tried every word that Wordle would accept for a fifth guess, but I still could not completely narrow down FIBER FIFER FIVER FIXER RIVER. The best I could do was REFIX, which would still result in a guess for the last round between FIBER and FIVER. Sure, given their use in English the answer is far more likely to be FIBER, but I still wanted to be able to narrow down all the words in my list.
For this, I needed to go back up a level.
The Four Guesses (Part II)
I decided not to completely rework my initial four guesses, only for the list that was giving me problems. I kept TEARS DOING LUCKY, but I needed to find a different fourth word that would split up that list differently than WHUMP. After three guesses, the problematic list is twelve words: FIBER FIFER FIVER FIXER MIXER RIMER RIVER WIVER RIPER VIPER WIPER PIPER. Many, many word attempts later, I found that a fourth guess of PILAF splits the list into:
| FIBER | MIXER | RIPER | PIPER |
| FIFER | RIMER | VIPER | |
| FIVER | RIVER | WIPER | |
| FIXER | WIVER |
Now that RIVER is in a different list, I could find fifth guess words for each sub list that would isolate each word. For most of my word list, WHUMP works fine as a fourth guess, but this branch is the one exception.
If I tried to beat every accepted word in Wordle (a feat I don’t even know is possible!), I would likely have to do much more of this. Perhaps I would have a set first guess or first two guesses, but the rest of the solution would be determined by an entire branching diagram based on those guess results. That sounds somewhat like how I play Wordle normally where my next guess is based on the previous results as well as the first words that come to mind. I don’t think I will ever try fully automating the game since that sounds like such an incredibly daunting task, but it makes for an interesting mental exercise.
How You Too Can Beat Wordle
Start with TEARS, DOING, and LUCKY as your initial guesses.
Is RIVER one of the possible answers given the results from those words? I.e., do your squares look like this?
⬛🟨⬛🟨⬛ (BYBYB)
⬛⬛🟨⬛⬛ (BBYBB)
⬛⬛⬛⬛⬛ (BBBBB)
In this case, use PILAF as your fourth guess. Use the following chart by finding the list with any possible remaining answers following that fourth guess (your answer word should be PIPER if you can’t find a list that fits). Then use the bolded word at the top as your fifth guess.
| VIBEX | RIVER | RIVER |
| FIBER | MIXER | RIPER |
| FIFER | RIMER | VIPER |
| FIVER | RIVER | WIPER |
| FIXER | WIVER |
For the vast majority of cases, however, you should use WHUMP as your fourth guess. Use this chart in the same way: find the list that has words that would work as solutions and use the word in bold as the fifth word. I am only listing lists with three or more possibilities, so if you can’t see any words that fit, you can probably brute force the answer since there should only be one or two words that work.

Your fifth guess should now narrow down your remaining possibility list to a single solution.
A note of caution: Wordle accepts many obscure words, so be careful what you enter in as your final answer. This procedure works with common words and all actual Wordle solutions, but it is not narrowing down the entire accepted word list. Be sure to think twice before hitting enter on anything you are not reasonably confident could be a real Wordle answer, as you may accidentally discover some archaic 18th century word that fits your square colors.
Conclusions
I should probably find other hobbies so I’m not using MATLAB for fun.
But beyond that, it’s quite impressive how much English can be narrowed down in a few guesses. Playing Wordle for hundreds of days has changed the way I see many words. Every now and then I’ll think of a five-letter word and make a mental note to use it in game because perhaps it has a lot of vowels or a common letter placement. The Tetris Effect is real and it will improve your vocabulary.

You must be logged in to post a comment.