Guess the hidden five-letter word in six tries. Type a word and press Enter, or click the on-screen keys. Each tile then shows green for a right letter in the right place, yellow for a right letter in the wrong place, and gray for a letter that is not in the word or whose copies are already used up.
Choose YOU PLAY to guess yourself, or AI PLAYS to let the solver choose. AI MOVE plays one guess, and AI AUTO keeps playing until the game ends or you press STOP.
The panel under the board lists the solver's best guesses with their expected bits, and the words still possible. NEW WORD starts a new game.
The solver keeps the candidates, the answers that agree with every feedback so far. For each allowed guess it works out how the candidates would split across the feedback patterns, then plays the guess that splits them best under its rule. The splits are read from a precomputed table, so each turn reads the table for every guess and counts the buckets, rather than recomputing any feedback.
The game scores each guess with a feedback pattern: five tiles, one per letter. A tile is green for the right letter in the right place, yellow for a letter that is in the answer in another place, and gray for a letter that is absent, or whose copies in the answer are all used up. Gray, yellow and green are the tile values 0, 1 and 2.1
Duplicate letters need care. Greens are settled first, and each green uses up one answer letter. Yellows are then handed out from left to right, and each one uses an unused answer letter of the same kind. So a guess with two E's against an answer with one E marks only the first E yellow, and the second stays gray.2
Example. Against the answer CRANE, the guess TARES gives .yyy.: T is absent, A, R and E are in CRANE in other places, and S is absent. Against the answer ABIDE, SPEED gives ..y.y. The first E is yellow because ABIDE has one E, the second E is gray, and the D is yellow.
A pattern is also a number. The five tiles are read as base-3 digits, with the first tile as the least significant digit. There are 35 = 243 patterns, from all gray (0) to all green (242). The all-green pattern is the win.3
Here p is the pattern id and t_i is the value of tile i: 0 for gray, 1 for yellow, 2 for green. Tiles are numbered from 0 at the left. The code computes the same sum by Horner's rule, which multiplies the running value by 3 and adds the next tile, starting from the last tile.
The rule itself is short. The simple version of the pseudocode below shows the core idea, and the full version follows the code step by step.
function FEEDBACK(guess, answer):
tiles ← greens where guess and answer agree, gray elsewhere
for each position i that is not green, left to right:
if an answer letter equal to guess[i] is still unused:
tiles[i] ← yellow # and that answer letter is now used
return the base-3 number of tiles # first tile least significant
function FEEDBACK(guess, answer):
tiles ← five gray tiles (value 0)
left ← empty map from letter to count
for i ← 0 to 4:
if guess[i] = answer[i]:
tiles[i] ← 2 # green
else:
left[answer[i]] ← left.get(answer[i], 0) + 1 # answer letters no green used up
for i ← 0 to 4:
if tiles[i] = 2:
continue # greens are already settled
if left.get(guess[i], 0) > 0:
tiles[i] ← 1 # yellow
left[guess[i]] ← left[guess[i]] − 1 # one unused answer letter is used
p ← 0
for i ← 4 down to 0: # Horner's rule: p = p · 3 + tile
p ← p · 3 + tiles[i]
return p
The full version counts the answer letters that no green used up, in a map called left. The yellow pass then reads that map, so a green is never given a yellow and a letter cannot be used twice. The Horner loop runs from the last tile to the first, which gives the same number as the sum above.
A game scores every allowed guess against every candidate, so the same feedbacks are needed again and again. The feedback table is therefore computed once for the lexicon, the two word lists together with this table. It has one row per allowed guess and one column per answer. Each entry is the pattern id for that pair, stored as one byte with values 0 to 242. A lookup is then a single array read.56
The table is built one guess row at a time. For each guess, PATTERN-ROW works on all answers together. This is vectorised code: one NumPy array operation, where NumPy is the array library the solver uses, covers every answer at once.7
function PATTERN-ROW(guess, answers): # one guess against every answer
green ← positions where the answer letter equals the guess letter
tiles ← 2 at green positions, 0 elsewhere
for each guess position i that is not green, left to right:
if an unused answer letter at some position equals guess[i]:
tiles[i] ← 1 # yellow, and that answer letter is used
return the base-3 pattern id of tiles, for each answer
function PATTERN-ROW(guess, answers): # answers: one row of 5 letter codes per answer
green ← (answers = guess) elementwise # A × 5 booleans
rem ← answers, with every green position set to −1 # −1: green, or an answer letter already used
tiles ← 2 where green, else 0 # A × 5
for i ← 0 to 4: # yellows, left to right over the guess
match ← (rem = guess[i]) # unused answer positions holding this letter
yellow ← (not green[:, i]) and (match has a true in its row)
tiles[:, i] ← tiles[:, i] + yellow
for each answer row r where yellow[r]:
j ← the first position where match[r, j] is true
rem[r, j] ← −1 # that answer letter is now used
return tiles · (1, 3, 9, 27, 81) for each answer # base-3 pattern ids
The full version checks the greens on every answer at once. A used answer letter is replaced by −1, which no letter code has, so it can never match again. The yellow loop then runs over the five guess positions, and each yellow uses the first unused matching position in its own row. Only the counts of letters matter for the score, so which matching position is used does not change the result.
The vectorised table is checked against the plain rule on 3,000 random guess and answer pairs, not on every entry.8 The table holds 6,748 guesses by 3,568 answers, which is about 24.1 million entries. Every answer is also one of the guesses, so each answer can be played and win.910
For a guess g and the candidates C, each feedback pattern p forms a bucket: the candidates that would give p if they were the answer. Let n_p be the size of bucket p. The buckets split the candidates, so their sizes add up to |C|, the number of candidates.
The answer is unknown, so every candidate is treated as equally likely. This is the uniform prior. Bucket p then has the probability P(p) = n_p / |C|, and the feedback is a random variable with that distribution. The code never forms P itself. It works with the counts n_p, and the formulas below are written in those counts.
The expected information of a guess, in bits, is the entropy of that random feedback. Entropy is the average surprise: pattern p is worth \log_2(1/P(p)) bits of surprise, and the entropy is the average of that over the patterns. One bit is the answer to one yes-or-no question.
Here n_p is the size of bucket p, and the sum runs over all 243 patterns. The code writes entropy in this form because it needs one count and one sum. The two forms agree: -\sum_p (n_p/|C|) \log_2 (n_p/|C|) = \log_2 |C| - (1/|C|) \sum_p n_p \log_2 n_p. An empty bucket adds nothing. The code takes \log_2 \max(n_p, 1), which is 0 when n_p = 0.
Two more numbers are computed from the same counts. The worst bucket W(g) is the largest bucket, the most candidates that can remain after the guess whatever the feedback.
The expected bucket size E(g) is the average size of the bucket that a random candidate falls into. A candidate falls into bucket p with probability n_p/|C|, so the average is the sum of (n_p/|C|) \cdot n_p.
Example. Identifying one of the 3,568 answers takes \log_2 3568 = 11.80 bits. The opener TARES has an expected information of 6.230 bits, a little over half of that, when all answers are candidates. Its largest bucket holds 251 answers, and a random answer falls into a bucket of 78.7 answers on average.14
The scores for every guess come from one scoring pass. The pseudocode below shows it. The candidates are passed in as answer indices, and the result has one number of each kind per allowed guess.
function SCORE-GUESSES(candidates):
for each allowed guess g:
n[p] ← number of candidates a with pattern(g, a) = p, for each pattern p
bits[g] ← log2 |candidates| − (1 / |candidates|) · sum over p of n[p] · log2 n[p]
worst[g] ← the largest n[p]
expected[g] ← (1 / |candidates|) · sum over p of n[p]²
return bits, worst, expected
function SCORE-GUESSES(candidates): # C = |candidates|
if C = 0:
raise ERROR("no candidates are left")
log_c ← log2 C
for each block of up to 1024 guesses, rows lo to hi − 1: # the block bounds the temporary array
pats ← table[lo to hi − 1, candidates], as 32-bit integers # pats[r, j]: guess lo + r vs candidate j
flat ← pats + 243 · r, for each row r # shift row r into its own 243 bins
counts ← COUNT(flat, 243 · rows bins), shaped rows × 243 # counts[r, p] = n[p] for guess lo + r
bits[lo to hi − 1] ← log_c − (1 / C) · sum over p of counts · log2 max(counts, 1)
worst[lo to hi − 1] ← the largest counts in each row
expected[lo to hi − 1] ← (1 / C) · sum over p of counts²
is-candidate ← false for every guess
is-candidate[guess index of each candidate] ← true
return bits, worst, expected, is-candidate
The full version works in blocks of 1,024 guesses, which bounds the size of the temporary array. Each row's patterns are shifted by 243 times the row number, so one COUNT, which is NumPy's bincount (it counts how often each integer occurs), counts the buckets of every guess in the block at once. The last step marks which guesses are candidates, so the strategies can prefer a guess that could win now.
The entropy strategy plays the guess with the largest H(g). A large entropy means many buckets of similar size, so the candidates shrink quickly whichever pattern comes back. The strategy sorts the guesses by the key below and plays the first one.
Here \operatorname{round}(\cdot, 9) rounds to nine decimal places, so floating-point noise cannot reorder guesses whose entropies are equal. The indicator \mathbf{1}[g \notin C] is 0 for a candidate and 1 otherwise, so among equal guesses a candidate comes first and can win this turn. The last entry is the guess's position in the sorted word list, which makes every tie resolve the same way on every run.
Over all 3,568 answers, the entropy strategy needs a mean of 3.627 guesses, and no game goes past six.14 Its best opener, when every answer is still possible, is TARES, at 6.230 bits. TARES is not an answer. The best opener that could itself be the answer is TALES, at 6.138 bits.
Minimax plans for the worst case. It plays the guess whose largest bucket is smallest, so that after the next feedback the fewest candidates can remain, whatever that feedback is. Ties go to the guess with the smaller expected bucket. It optimises a different target from entropy, not a blend of the two.
The key is read in the same way as the entropy key. The first entry, the worst bucket, is the primary rule. The second entry breaks ties with the expected bucket size, and the last two are the candidate preference and the list position.
Minimax needs a mean of 3.739 guesses, with no failures. On average it takes a little longer than entropy.14
The random consistent strategy picks one candidate at random. Every candidate fits all the feedback so far, so it uses every clue. It never compares guesses, which makes it the baseline the other two are measured against. The pick is drawn from the answers still possible, not from the full guess list.
Here \operatorname{Uniform}(C) gives each candidate the same probability, 1/|C|. The code draws the guess with a random number generator, rng.choice, over the candidate list.
The random baseline needs a mean of 4.412 guesses. 246 of the 3,568 games, or 6.89%, run past six guesses.14
A turn has three steps. The strategy picks the guess, the game scores it against the hidden answer, and the candidates are narrowed to those that would have given the same feedback. The narrowing is the whole update. It needs nothing beyond the candidate set.19
Here g is the guess, p the feedback it received, and \text{table}[g, a] the pattern of guess g against answer a. The candidates after the turn, C', are the candidates whose pattern against g is p.
The server and the terminal report the bits gained by a guess as the real split of the candidates: the log base 2 of the candidates before the guess over the candidates after it. That figure is shown next to the bits the scoring pass expected.
The page's panel under the board lists eight guesses: the top eight in the order the strategy uses, or, for the random baseline, eight candidates in random order. Each bar's length is that guess's expected bits, as a share of the largest of those eight.23
The whole choice is made by CHOOSE. The simple version shows the idea, and the full version adds the single-candidate rule, the random branch and the opening cache.
function CHOOSE(candidates, strategy):
if there is one candidate:
return that candidate as the guess
if strategy is random:
return a candidate picked uniformly at random
bits, worst, expected, is-candidate ← SCORE-GUESSES(candidates)
return the guess that comes first in the strategy's order
function CHOOSE(candidates, strategy, rng):
if strategy is not entropy, minimax or random:
raise ERROR("strategy must be one of entropy, minimax, random")
if |candidates| = 1: # one candidate left: guess it
return the guess index of that candidate
if strategy = random:
if rng is missing: rng ← a new unseeded generator
return the guess index of rng.choice(candidates) # uniform over the candidates
opening ← (|candidates| = number of answers) # no feedback yet
if opening and the cache holds the scores:
take the cached scores
else:
bits, worst, expected, is-candidate ← SCORE-GUESSES(candidates)
if opening: store the scores in the cache
if opening and the cache holds the order for this strategy:
take the cached order
else:
order ← guess indices, sorted by
entropy: (−round(bits, 9), not is-candidate, index)
minimax: (worst, round(expected, 9), not is-candidate, index)
if opening: store the order in the cache
return order[0]
The full version caches the scores and the order on the lexicon when all answers are still candidates. That is the first turn of every game, and it is the same every time, so the work is done once. In CHOOSE, a single remaining candidate and the random strategy skip the scoring pass.
None of the three rules is tuned or learned. Each score is the objective its strategy names, and the feedback rule is fixed by the game. Exact ties go first to a candidate, which can win this turn, and then to the earlier word in the sorted list, so results repeat exactly.27 Bits are rounded to nine decimal places before comparison, so floating-point noise cannot reorder near-equal guesses.28
The random strategy draws from a generator seeded per answer, so its benchmark numbers repeat as well. The seed is the benchmark seed times 100,003 plus the answer's index.2930
The answers are 3,568 common five-letter words from the small tier of SCOWL, the Spell Checker Oriented Word Lists by Kevin Atkinson. The guesses add the rest of SCOWL's five-letter words from the large tier, for 6,748 allowed guesses. Only lowercase a–z words of exactly five letters are kept, so names, abbreviations, possessives and accented words are dropped.313233
The bundled answer and guess lists are plain text files with one word per line.3435 The official Wordle lists are not used, so the numbers on this page are not directly comparable with published Wordle results. SCOWL's notice grants permission to use and distribute the lists for any purpose without fee, and the full notice ships with the data files.36
The benchmark plays every answer with each strategy, starting from all answers, and counts the guesses. The count includes the winning guess. A game that is not solved within six guesses is a failure, recorded as 7.3738
function PLAY(answer, strategy):
candidates ← all answers
for turn ← 1 to 6:
g ← CHOOSE(candidates, strategy)
if g is the guess for this answer:
return turn
candidates ← the candidates that give the same feedback as the answer
return 7 # failed: not solved in six guesses
function PLAY(answer, strategy, seed):
rng ← a generator seeded with seed · 100003 + answer index
candidates ← all answers
target ← the guess index of the answer
words ← empty list
for turn ← 1 to 6:
g ← CHOOSE(candidates, strategy, rng)
append word g to words
if g = target:
return turn, words # solved on this guess
candidates ← NARROW(candidates, g, table[g, answer])
return 7, words # failed: the answer was not reached
The full version passes the same random generator into every CHOOSE call, so a seeded run repeats exactly. The table entry table[g, answer] is the feedback the answer would give, and NARROW keeps the candidates that would give the same feedback.
The benchmark is run with python -m wordle benchmark, which writes the files that the table below is taken from.40 The table shows the committed run: guess counts from 1 to 6, the failures, and the time that run took, which depends on the machine. A fresh run of the same command reproduces every count.14
| Strategy | Mean | 1 | 2 | 3 | 4 | 5 | 6 | Failed | Seconds |
|---|---|---|---|---|---|---|---|---|---|
| Entropy | 3.627 | 0 | 59 | 1,513 | 1,710 | 272 | 14 | 0 | 241.8 |
| Minimax | 3.739 | 0 | 50 | 1,223 | 1,927 | 344 | 24 | 0 | 332.6 |
| Random | 4.412 | 1 | 94 | 699 | 1,274 | 886 | 368 | 246 | 0.8 |
The entropy and minimax strategies lose no game in six guesses. The random baseline loses 6.89%.