The right way to play Wordle
We all know wordle: one word, five letters, 6 attempts.
I have gotten into the habit of playing with my friends. I am pretty good, I have to admit. But I am pretty competitive. Although I usually come on top, I needed a more reliable way to come on top.
So lets model it.
The Game
Wordle is a very simple game. You have 6 guesses to figure out a 5 letter word. Every guess gives you further information on the correct answer.
A yellow square means the letter in that spot is in the final word. A green square means the letter is both in the word and in the correct position. If the square lights gray, the letter is not in the word.
A bit of hacking tells us there are 2,315 correct answers and 12,972 allowed words. The gap makes it possible to guess words that are never possible.
So Wordle is a game of guessing. Each guess brings you more information on what the final word is. This links very well with information theory.
Information Theory
Information theory is a framework to study data. I am not going to make this a lecture on information thoery (for that, Claude Shannon’s A mathematical thoery of communication is amazing).
Some concepts worth introducing:
-
Self-information is how much “surprise” an outcome carries. An outcome with probability carries
For example, a rare word has a small probability and hence a high self-information.
It is a log function, so very independent events (non-related), which are multiplying probabilities, increase the information.
The units for self-information is the bit. Each bit is one halving of the possibilities. i.e. 1/8 = = 3 bits
-
Entropy is the expected self-information: how much you learn on average, before you know the outcome.
It is a previous guess based on what every outcome could produce.
is high when therer are many possible equally likely outcomes, nearly zero when one outcome dominates the others.
The case for Wordle
Every guess gives an answer on what the outcome looks like. Every possible answer pattern is a possiblity. Every tile is one of three colours, so a single guess can return at most distinct patterns.
Every guess sorts every possible answer into one of these buckets. Once we get the answer, only one survives.
Over the set of still can happen answers, the probability of pattern is just the fraction of answers that would produce it:
Drop that into the definitions from before. The self-information of actually seeing pattern is i.e. how much that specific result narrowed the field. And the entropy of the guess is the expected bits it will teach you:
So, to recap:
- a high entropy splits the buckets into many even buckets.
- a low entropy H give a huge bucket with very high chances of happening (you learn nothing)
The best guess is the one with the highest entopy amongs those available.
For a possible guess, work out the pattern it would produce against every possible answer, tally the buckets, and sum:
from collections import Counter
from math import log2
def entropy(guess, answers):
buckets = Counter(pattern(guess, answer) for answer in answers)
total = len(answers)
return sum((n / total) * log2(total / n) for n in buckets.values())
Calling pattern(guess, answer) gives the green/yellow/gray key for that pairing. We score very possible word, sort by entropy and the #1 will be the most informative opening.
We then repeat it on what survives and we will get a mathematically clever way to play the game!!
Not so quick, greedy
The greedy approach of picking the best answer always, turns out, is not the best. One guess is scored in isolation:
To play to actually win, you score a guess by the whole game it leads to. The expected number of guesses left once you account for every reply it could get, and the best follow-up to each:
This is much more expensive, since you have to search all the possible options. Entropy is a cheap approximation of this, but it is the best answer.
Two objectives, worth keeping straight:
- Entropy answers “which guess teaches me the most, right now?” — cheap, greedy, one step.
- The full search answers “which guess wins in the fewest turns, all the way down?” — expensive, optimal, the whole tree.
The optimal after doing the full tree search comes out to guesses per game. Greedy entropy comes in around , barely a fraction of a guess behind. So play harder, not smarter. Unless you are lazy, then definitely play smarter because it is a lot less work.
Solving
Coming soon…
I recovered this blog post from my backlog, it is now updated at July 15 2026.
References
- Claude Shannon, A Mathematical Theory of Communication — where self-information and entropy come from
- Alex Selby, The best strategies for Wordle — exhaustive search for the optimal opener (the 3.42 result)
- Laurent Poirrier, Wordle-solving state of the art — survey comparing greedy-entropy and optimal play
- Bertsimas & Paskov (MIT), An Exact and Interpretable Solution to Wordle — the optimum re-derived with exact dynamic programming
- Greenberg, Effective Wordle Heuristics — how close common-word-only play gets to optimal
- Lokshtanov & Subercaseaux, Wordle is NP-hard — why solving it optimally has no shortcut in general