Can we always solve Wordle “offline” with fixed guesses?
tl;dr
No, but almost.
Alexandre Salle, Virgile Andreani and David Rusin found multiple strategies that solve all Wordle puzzles “offline” in as low as 7 guesses (6 fixed guesses + 1 winning guess).
With a set-cover formulation and a MIP solver, it can be shown that it is impossible to do the same within 6 guesses. In that sense, the above strategies are thus optimal for offline Wordle.
If we do not exploit the 2309-word solution list, we need 11 guesses (10 fixed guesses + 1 winning guess).
Using fixed guesses: offline Wordle / blindfold Wordle
Back in February, Alexandre Salle proposed an interesting Wordle-solving challenge: Can we solve every Wordle puzzle with a fixed set of initial guesses? Specifically, the challenge is as follows. Find words such that:
- We always play those same words as our initial guesses, without looking at the game’s answer.
- Then, after the th guess, we observe the game’s answers and infer the secret word.
- At the th guess, we always correctly find the secret word.
Alexandre refers to this as solving Wordle offline, as opposed to using a decision tree. Indeed, a decision tree can tailor each guess online knowing the game’s answer to previous guesses, to improve our chances of winning quickly. An “offline” approach is much more constrained. The term blindfold Wordle, to describe the same problem, is due to Alex Selby.
The question here is: What is the value of , the smallest such that an offline strategy exists? In particular, can we find a strategy with fixed guesses? Together with the final (non-fixed, winning) guess, this would mean winning 100% of the 2309 Wordle puzzles within the 6 allowed guesses. Note that at first, we will exploit the fact that, among the 12974 allowed guess words, only 2309 are possible secret words.
Upper bounds on
In his February post, Alexandre found a first strategy with fixed guesses. In March, Virgile Andreani found a set of 7, then fixed guesses that lets you win with the seventh, thus tantalizingly close to our objective of always winning Wordle in 6 turns with fixed guesses! In May, David Rusin found another 6-fixed-guesses strategy, but one which satisfies an additional constraint: David’s guess words are picked exclusively from the 2309-word solution list (the solution lists only features fairly common words, whereas the validity of some of 12974 dictionary words may be debatable). The fact that is possible in such a restricted setting gives hope for an strategy, but none had been found.
Lower bounds on
When Alexandre told me about solving Wordle offline, I briefly considered formulating it as a satisfiability (SAT) or mixed-integer programming (MIP) problem. Unfortunately, any formulation I came up with had either too many variables, or too many constraints to even fit in memory – let alone be solved.
But then recently David Rusin kindly explained to me his approach. In the process of finding his set of 6 fixed guesses, he meticulously determined a list of 916 pairs of words that are somehow very similar in terms of Wordle’s answers, hence difficult to disambiguate with Wordle guesses (he calls them toughpairs). This opens up a new possibility.
Indeed, the problem of determining the Wordle secret word with fixed guesses can be stated as follows. We are guaranteed to discover the secret word if and only if, for every possible pair of possible secret words, one of our guesses gets a distinct game answer for the two words in the pair. In other words, for every pair of words, we must disambiguate between them with at least one of our guesses.
This is a very straightforward set-cover problem; it would make a great first exercise in an introductory optimization class. We have 12974 binary variables, one for each possible word. We decide that each will take a value 1 if we use the corresponding word as a guess, 0 otherwise. We will minimize , whose value is the sum of our variables. Then, we have one constraint for every possible pair of secret words, stating that among all the guesses that disambiguate between those two secret words (i.e. the variables that cover this pair), at least one must be taken.
In mathematical terms, our model takes the following form. Let be the index set of all words, and let be the index set of all the possible pairs of secret words. We construct a constant matrix that satisfies The model is then the usual set-cover formulation or, more concisely,
Unfortunately, our MIP model has constraints, one for each pair of words. The performance of MIP solvers these days is fantastic, but two million constraints is still rather large for a MIP formulation.
However, we can construct a relaxation of this problem, by considering only constraints, where is the set of David’s carefully curated “toughpairs”. Using just those 916 pairs (instead of 2,664,586) as our set-cover constraints, we obtain a relaxed model that is much more amenable to tackling with a MIP solver. David kindly provided me with the matrix . You can download the resulting LP file here. All I did is feed it to Coin-OR’s open-source MIP solver Cbc, and it returned an optimal solution of value after 83 seconds. In other words, with guesses, it would be impossible to disambiguate between David’s 916 pairs of secret words, let alone solve Wordle entirely.
Update 2022-08-13: Using this MIP approach, David Rusin also showed that, in the context of picking the guesses exclusively from the 2309-word solution list, his solution is actually unique. He proceeded by solving 6 MIPs, in each one removing one of his 6 words from the allowed guesses. In each case, it became impossible to identify the secret word within 6 fixed guesses.
Targeting the full 12974-word dictionary
Added 2022-08-20. In an email conversation spurred by Mark Fisher’s interest in -Wordle Alex Selby pointed out a link between -Wordle and offline/blindfold Wordle. In -Wordle, one finds secret words simultaneously with a single set of guesses. After each guess, the game provides answers, one corresponding to each secret word. Many such games can be found on the web, for example dordle for , or sedecordle for .
Alex’s link is that is an upper bound on the number of guesses necessary to solve -Wordle. Indeed one can play the fixed set of guesses as if playing offline Wordle. Then, the information gathered should be sufficient to solve all puzzles in one guess each.
Mark is interested in bounds for -Wordle targeting the full 12974-word dictionary (i.e., not exploiting the 2309-word solution list), so I tried to apply the same MIP approach to this case. Unfortunately, I did not have David Rusin’s “toughpairs” for the whole dictionary, so I adopted the following approach:
- Start with a candidate set of offline guesses (initially, David’s 6 guesses).
- Determine all the sets of secret words that are not disambiguated by those offline guesses. If we play those guesses, the game’s answers will be identical for any secret word . Same for any , and so on.
- For every such that , add to our list of toughpairs.
- Build a set-cover formulation with one constraint per toughpair.
- Feed the formulation to a MIP solver, get a new candidate set of offline guesses, go back to 1.
After 8 iterations of this process, I obtained 4936 pairs, but unfortunately the MIP solves were exceeding an hour, while only adding a few dozen pairs to the formulation each time. However, a clear pattern was emerging. Most pairs were composed either (a) of words that differed only in one letter position, or (b) of words that were permutations of each other’s letters. We need to strike a balance here. Adding all such pairs yields a gigantic MIP formulation (a 2.2 GB lp file!) that cannot be solved. Adding too few would not sufficiently accelerate the above iterating process. After some attempts, I settled on all 2721 pairs of words that differed in at most two positions and were composed of the same letters. Adding them to the list of pairs already found, I obtained a set-cover formulation with 12974 variables and 6890 constraints. It was solved in a few hours, giving the 10 fixed guesses:
defer myrrh going ajwan beaux klett punny spods villi zocco
This solution is not necessarily the only one with 10 fixed guesses, but the MIP solver did prove optimality (i.e., 9 is impossible). Counting the final correct guess, we thus need 11 guesses to solve offline Wordle if we don’t exploit the 2309-word solution list. Coming back to -Wordle, Alex’s strategy now provides an upper bound of guesses.
Conclusion
The strategies found by Virgile
Andreani (combo, fatty, grrrl, spuds, venge, whilk
),
and David
Rusin (catty, frond, rumba, spill, verge, whack
), which
solve Wordle offline within 7 guesses, are optimal. It is
impossible to solve Wordle offline within 6 guesses.
The next best thing, however, is still possible: One can solve all the Wordle puzzles with a hybrid approach starting with 3 initial fixed guesses, then following multiple tiny 2-deep decision trees.
And if you prefer full-on decision tree approaches, see my Wordle-solving state of the art survey.