Choosing Wordle words

David Lee
3 min readFeb 12, 2022

--

In a prior post, I described how the opening word choice in Wordle impacts the probability of winning. In this post, I present an algorithm for subsequent word choices.

Using this algorithm, the probability of winning in 6 moves using the opening word ‘blimp’ rises from 96.81% to 97.72%. The probability of winning in 3 moves using the opening word ‘slate” rises from 29.33% to 35.11%. These are both solid improvements.

The algorithm optimizes guesses by first choosing all words that match all scores given so far. Then it weights letters based on how close they are to the center of letter frequency in set. That way, on each letter dimension (up to 26 for a-z) the space is as much as possible divided in half. In computer science, doing this one dimension this is called a binary search. The steps are:

  1. Find all words that match constraints of scores from prior guesses.
  2. Ignoring green matching letters, determine how often each letter is used in that set of words.
  3. Score each of the words by how well each letter divides the words. Letters in half the words score well. Letters in just one or all of the remaining words score poorly.
  4. If a letter appears multiple times in a word, score the first instance normally and give each other instance the lowest possible score. Using the same letter multiple times doesn’t divide the space well.
  5. Choose the word with the best score.

This algorithm is much more computationally expensive than choosing a next word at random — the app runs about 5 times slower in this mode. It’s also much less subject to differences from run to run when the dictionary word order is randomized. Instead of running 20 iterations to find the best and worst starting words as I did when words were chosen randomly, I only had to run 4 iterations to ensure results were stable.

For fun (and to test if the algorithm was working) I re-ran the app with a change where it chooses the worst available next move. As you can see, good word choices lead to slightly better outcomes than random. But bad word choices are significantly worse than random.

Below are the best and worse opening words for winning in 3 and 6 moves for each of random, good, and bad word choice.

A few things to note:

  • By choosing the best possible move on each turn, you can still only win 98% of games. Words like ‘night’, where many other words differ just in the first letter, mean getting to 100% won’t happen without luck.
  • Even if you choose the worst possible moves after a decent opening move, you still have an 86% chance of solving Wordle.
  • Even if you choose the worst possible moves every turn, you still have a 56% chance of solving Wordle.
  • I didn’t consider taking moves that conflict with scores from prior moves, but it’s easy to see that you can lose every game :)
  • I’m certain there are better algorithms than the one I propose here. Do you have one? Can you win 100% of games? Let me know!

My code can be found here: davidly/wordle: wordle generation and solution app (github.com)

--

--

David Lee

Seattle software engineer, adverb, seeker of musical transcendence. he/him/cis/white/straight/old/ugly/dull