Live data from Hacker News

Solving Wordle in 3.64 guesses on average, 99.4% of the time

lockwood.dev

81–90 of 181 posts

Re: Solving Wordle in 3.64 guesses on average, 99.4% of the time

#81

I wrote a solver a few weeks ago that solves easy mode in 3.45 guesses and hard mode in 3.55 guesses. Rather than using heuristics, it explored a large portion of the game tree (with a little pruning) and I'm hopeful that it's optimal. Interestingly, the EV-optimal hard mode strategy takes 3.52 guesses on average, but requires 7 guesses a tiny fraction of the time, so I instead exposed the best strategy that always r…

It fails with the word "frogs", as it tells me it is "gross"

Re: Solving Wordle in 3.64 guesses on average, 99.4% of the time

#82
post #33

This [1] solves it in 3.4212 average guesses 100% of the time and claims optimality, which is 99% of the difficulty it seems. For the limited 2671-word set of possible words, I think the question is now settled (for the whole 12k-word set, I don't think anyone tried anything). It was posted here four days ago [2]. [1] http://sonorouschocolate.com/notes/index.php?title=The_best_... [2] https://news.ycombinator.com/ite…

Neat, didn't know that existed! Definitely would have saved me some time :)

FWIW, I wrote a similar solution a couple of days ago as well, and come up with the same result (3.421166 guesses on average, with starting word SALET). So that would support that result.

With the following strategy: https://drive.google.com/file/d/1WvxRRzbvDVnHZUczHBZAko3hKft..., code: https://drive.google.com/drive/folders/1Y8k685PS0wxvYulIxsPg...

Re: Solving Wordle in 3.64 guesses on average, 99.4% of the time

#83
post #31

Earlier quoted context omitted.

As a point of curiosity, what do you mean by optimal? To me, I can see at least two (potentially different) cost functions that a Wordle strategy can aim to minimise. Firstly, you can try to minimise the expected number of guesses, and secondly you can try to minimise the expected number of guesses conditional on never losing the game. In principle you could optimise for the first but not the second by allowing a sma…

Funnily enough, I think neither of those notions are the correct thing to optimize. For me, you want to minimize the maximum number of guesses. This leads to an equilibrium. Otherwise, your opponent can just abuse your strategy.

Adversarial strategies are another type of problem entirely (as in, if you're playing Word Mastermind). Wordle is a 1-player game, so I find hgibbs's comment totally reasonable. I would think that 'optimal' is more accurately his second definition - minimizing avg guesses but always winning (as in, losing is +inf guesses).

Re: Solving Wordle in 3.64 guesses on average, 99.4% of the time

#84
post #79

Earlier quoted context omitted.

I don't think it works for easy mode either. The overwhelming majority of 6-word sets can be distinguished in two guesses in easy mode (their EV is either 11/6 or 2), while this set has an EV that's around 3.

for this specific set in easy mode doesn't (bawds, chefs) result in unique responses for all of them? so that's 2.5 guesses total? Where are you getting the EV for 6-word sets?

You're right: the EV is 2.5 (my guess was pessimistic). For (almost all) 6-word sets, there's a single word you can use to delineate all six words, which gives an EV of 1.83 if that word is in the set and 2 if it isn't.

Re: Solving Wordle in 3.64 guesses on average, 99.4% of the time

#85
post #38

>so far what was taking 1GB of RAM in Python is taking, literally 1MB in Rust Is anybody hiring people to fix situations like this at work? i.e. this script that was written in a hurry needs to be revised to be 10^3 times more efficient, in space or time.

I did this at an internship of mine. You aren't really going to be hired for "please fix our script's performance", but you might end up finding a place where you have the opportunity to do this kind of thing.

Re: Solving Wordle in 3.64 guesses on average, 99.4% of the time

#86
post #31

I wrote a solver a few weeks ago that solves easy mode in 3.45 guesses and hard mode in 3.55 guesses. Rather than using heuristics, it explored a large portion of the game tree (with a little pruning) and I'm hopeful that it's optimal. Interestingly, the EV-optimal hard mode strategy takes 3.52 guesses on average, but requires 7 guesses a tiny fraction of the time, so I instead exposed the best strategy that always r…

As a point of curiosity, what do you mean by optimal? To me, I can see at least two (potentially different) cost functions that a Wordle strategy can aim to minimise. Firstly, you can try to minimise the expected number of guesses, and secondly you can try to minimise the expected number of guesses conditional on never losing the game. In principle you could optimise for the first but not the second by allowing a sma…

IMO, never losing the game is the bare minimum for any reasonable cost function: never take > 6 guesses. Beyond that, you can have different optimization functions based on whether you're trying to minimize the worst-case depth of the decision tree (number of guesses) for each position, or the average depth, or some other reasonable function of the distribution over number of guesses.

Although you could have arbitrarily many cost functions, a fairly general class is the following: pick some nonnegative constants (w1, w2, w3, w4, w5, w6, w7), and for a certain strategy, define the cost as:

    w1*n1 + w2*n2 + w3*n3 + w4*n4 + w5*n5 + w6*n6 + w7*n7
where nk (for 1≤k≤6) is the number of hidden (solution) words for which the strategy takes n guesses, and n7 is the number of words for which the strategy loses the game. Then,

• Setting w7 infinite / very high is a way of encoding the condition that you not lose the game. (You can set it finite/small if you don't mind occasionally losing the game for some reason!)

• Setting w1 = 1, w2 = 2, …, w6 = 6 will simply minimize the average number of guesses,

• Having them grow exponentially, e.g. setting wk = c^(k-1), where c is some constant larger than 12972 (the number of acceptable guess words) will make sure that the minimal-cost strategy first minimizes the maximum number of guesses, then break ties by having the fewest words take that many guesses, and so on.

Re: Solving Wordle in 3.64 guesses on average, 99.4% of the time

#87
post #22

As many have mentioned, it seems much more efficient to focus on eliminating letters, which means that the second word should not be very green at all. Also, since there's only one word a day, I think we can assume that it's chosen manually, and it won't be some archaic anglo-saxon tool for shoeing horses or something, it will be a relatively common word.

I think it's chosen based on a random number generated from the date - but one of the most recent games had the answer "REBUS", which I've never heard or read before. But yeah, the target list has many more common words in it than the list of all possible guesses.

That is not an uncommon word though, I'd venture most school children know it. You probably read rebuses in school but just forgot about it!

Re: Solving Wordle in 3.64 guesses on average, 99.4% of the time

#88
post #30
post #22

As many have mentioned, it seems much more efficient to focus on eliminating letters, which means that the second word should not be very green at all. Also, since there's only one word a day, I think we can assume that it's chosen manually, and it won't be some archaic anglo-saxon tool for shoeing horses or something, it will be a relatively common word.

It says it is designed for hard mode, in which I believe you must use your green (and maybe yellow?) letters.

Oh, didn't know there was modes.

Re: Solving Wordle in 3.64 guesses on average, 99.4% of the time

#89

Why not simply choose a guess which narrows the set of possible solutions the most? This could be improved by looking one step further, but this would probably require some kind of optimization / heuristic / approximation to make it computationally feasible.

Narrowing the search space greedily doesn't solve the problem optimally, because the size of the search space is just a heuristic. Some search spaces of size X might be more difficult to reduce further than another search space of size Y (for Y < X). This is more apparent in hard mode where you have a very limited guess-pool. The greedy heuristic approach would work fine if all possible 5-letter combinations were valid answers.

Re: Solving Wordle in 3.64 guesses on average, 99.4% of the time

#90

https://github.com/JuanPotato/Wordle-Solver I made a similar solver, it solves all the words in 3.65 average moves. Could probably be better. The github explains how it works.

Neat! I came up with a similar statistic (3.65 average moves, hard mode, no failures) using a very simple heuristic.

  1) pick a first guess, and partition the remaining words by the hints that they give

  2) given any part of a partition, pick a word that minimizes the maximum-size part of the resulting sub-partition

  3) repeat (2) until words are solved.
I brute-forced the first guess (that is, generated a tree rooted at each word), and the best one was 'bland'. That has one failure, getting stuck on the chain (hound, mound, pound, sound), which ended up being easy to fix manually.

My tree is quite different from yours, with guess distribution 1, 103, 861, 1114, 212, 24.

Post reply on HN