Wordle

Samson

Deity
Joined
Oct 24, 2003
Messages
19,603
Location
Cambridge
You know this wordle thing everyone is talking about, that was bought for millions? It has been implemented in 50 lines of bash. It works with just these commands:
Code:
$ wget https://gist.githubusercontent.com/huytd/6a1a6a7b34a0d0abcac00b47e3d01513/raw/ca41929c10a6c2ed8faa77c298bb188abfe5145a/wordle.sh
$ bash wordle.sh
The "clever" bit, ie. the bit that gives you the colour coded hints about which letters are right, is this few lines:
Code:
                for ((i = 0; i < ${#actual}; i++)); do
                    if [[ "${actual:$i:1}" != "${guess:$i:1}" ]]; then
                        if [[ "$remaining" == *"${guess:$i:1}"* ]]; then
                            output+="\033[30;103m ${guess:$i:1} \033[0m"
                            remaining=${remaining/"${guess:$i:1}"/}
                        else
                            output+="\033[30;107m ${guess:$i:1} \033[0m"
                        fi
                    else
                        output+="\033[30;102m ${guess:$i:1} \033[0m"
                    fi
                done
                printf "$output\n"
However I think there are some hard words on my system:
Code:
$ grep '^\w\w\w\w\w$' /usr/share/dict/words | head
aahed
aalii
Aalst
Aalto
AAMSI
AAPSS
Aarau
Aaren
aargh
Aaron
 
Last edited:
Wordle is very popular, but I have never played - nor read about its mechanics.
The only time I have ever played is trying out this code. It seems really hard, there are 24 thousand 5 letter words in the list it picks on my machine, you only have 6 guesses. I feel I should be able to work out how many paths you could take, but I cannot be bothered. Of the top of my head it seems like there is too much randomness to give you a good chance of winning a game.
 
So it first asks you to put in a random 5-letter word, and then colors show which letters (and where?) are correct? (iirc also if other letters are correct, but not in the right position).
Randomly, you start with (not practically, if it is only real words and not aaaaa) close to 1/26^5 (1/11881376), but in reality you have a pretty good chance of some common letters being there (I think "e" is the most common in english).
The upper limit of 24.000 you mentioned, already by default would mean you have 1/24000 if you inserted a real word, which is roughly 500 times more of a chance if this was random letter arrangements.

Actually I'd prefer it if it was random. Not much point in generalizing when there is an arbitrary limit.
 
Wordle is a lot of fun, and I haven't lost a game yet.

There are 26 letters in the alphabet, and 5 of them are in the word. On your first guess you have a chance of 5/26 of matching at least one letter, which is very good. If you try different words using different letters, you will have 20/26 by the time you have made your 4th guess. While it's possible you won't have uncovered any letters yet, it's statistically unlikely. Once you get a few letters, either Yellow (present but wrong position), or better yet Green, it's not too difficult to start working out what the word might be. Having letters eliminated helps a lot too with narrowing down what is in the word.

If you haven't played then I highly recommend it, the game is a lot of fun!

https://www.powerlanguage.co.uk/wordle/
 
Last edited:
Wordle is a lot of fun, and I haven't lost a game yet.

There are 24 letters in the alphabet, and 5 of them are in the word. On your first guess you have a chance of 5/26 of matching at least one letter, which is very good. If you try different words using different letters, you will have 20/26 by the time you have made your 4th guess. While it's possible you won't have uncovered any letters yet, it's statistically unlikely. Once you get a few letters, either Yellow (present but wrong position), or better yet Green, it's not too difficult to start working out what the word might be. Having letters eliminated helps a lot too with narrowing down what is in the word.

If you haven't played then I highly recommend it, the game is a lot of fun!

https://www.powerlanguage.co.uk/wordle/
I think the maths is slightly more complicated than that (it is not taking into account duplicated letters, and p of a hit in 4 goes is not 4 * p of a hit in 1 go), but if you say you have not lost a game my intuition must be wrong. It must be a solvable problem, if you play optimally what is your chance of winning? If I was more bored I would give it a go.
 
I think the maths is slightly more complicated than that (it is not taking into account duplicated letters, and p of a hit in 4 goes is not 4 * p of a hit in 1 go), but if you say you have not lost a game my intuition must be wrong. It must be a solvable problem, if you play optimally what is your chance of winning? If I was more bored I would give it a go.
Nah, the math really is that simple. This is not a difficult game, but is a lot of fun to play. As far as chance of winning, well so far I'm at 100% and so I can't really answer that one. I'd say you're capable of solving it every day.

What you're forgetting is that you can consider 4 attempts with 5 different letters each time as a single go of 20/26. Also when you then consider that many letters are more common than others, your chances increase dramatically. With 4 attempts you can test all the vowels, which guarantees you that you're going to have at least one hit. You also can know which types of letter combinations generally work together. Remember that this is a word puzzle, not a mathematics puzzle.

The game takes 5 minutes to play.
 
Just read that the proof Derbyshire gives of the following identity, in his book about Riemann, is mostly the proof Euler himself provided. Which is great, since indeed it is the easiest proof to follow, and leads from the Sieve of Eratosthenes to this formula in less than half a page :)

upload_2022-2-2_18-55-1.png


I am happy that I am becoming interested; the author deserves almost all of the credit for that.
 
Nah, the math really is that simple. This is not a difficult game, but is a lot of fun to play. As far as chance of winning, well so far I'm at 100% and so I can't really answer that one. I'd say you're capable of solving it every day.

What you're forgetting is that you can consider 4 attempts with 5 different letters each time as a single go of 20/26. Also when you then consider that many letters are more common than others, your chances increase dramatically. With 4 attempts you can test all the vowels, which guarantees you that you're going to have at least one hit. You also can know which types of letter combinations generally work together. Remember that this is a word puzzle, not a mathematics puzzle.

The game takes 5 minutes to play.
I am not arguing with your point that it is generally solvable. I will accept your word on that. However your statements about probability seem wrong to me.

> On your first guess you have a chance of 5/26 of matching at least one letter

If these were random strings of letters, picked without replacement, that would be the lowest p, right? For 1 letter guess vs. 1 letter word the chance of matching is 1/26, 2 letter guess vs. 1 letter word would be 2/26-1/(26^2) = 1/13.2549. I should be able to expand this to 5 letters, but I cannot be bothered, but it is not going to be 5/26. Is it Kyriakos's function? I am not sure without thinking a bit more than I want to right now.

However they are not picked without replacement. The second on my list is aalii, so only 3 distinct letters. If this was matched against a random string of 1 letter that would give you less than 3/26.
 
Since it isn't random strings, but real words, you'd have to calculate (boring) stuff including that (iirc) you can't have three consecutive vowels in an english word (edit: there is 'queue', but pretty rare). It will be boring to amass all the restrictions, but maybe some or most can amount to nothing, in practice. I doubt this is a game which would interest from a mathematical point of view, due to the restrictions from language as well as (apparently?) individual closed-system pool of words.
 
Yeah, I guess the math is more complicated, but definitely not on the list of unsolvable. Because at worst with 5 tries before the last you get 5x5 letters as tries, although you will not be able to test all, since they're not independent and need to be real words, but you can get close to it. This all considering that you're not using the gained knowledge if a letter is in the word and at which position it is.
Someone did some math already for it, see https://kotaku.com/wordle-best-worst-starting-word-help-tips-guide-1848446433 .
 
Yeah, I guess the math is more complicated, but definitely not on the list of unsolvable. Because at worst with 5 tries before the last you get 5x5 letters as tries, although you will not be able to test all, since they're not independent and need to be real words, but you can get close to it. This all considering that you're not using the gained knowledge if a letter is in the word and at which position it is.
Someone did some math already for it, see https://kotaku.com/wordle-best-worst-starting-word-help-tips-guide-1848446433 .

I mean, obviously the math wouldn't be "unsolvable", or even that complicated. Still, there are a number of parameters to take into consideration, starting with the fact that the pool of available 5-letter words must be specific (and non-changing regardless of when you play). Samson was alluding to the very significant difference among probabilities with repetition, and without, and in this case you have limited repetition (it's why I mentioned successive vowels, or consonants, in actual english words). If this was a random string of letters, the math is different and some parameters are not in play.

Tldr: if you actually knew what percentage of real 5-letter words use (say) over two consecutive vowels or consonants, you could factor that in for increasing your chance slightly. Same goes for knowing how common each letter is in that available pool of letters. That, and similar, make this less about math and more about having specific (arbitrary) constants that function along with the actual math stuff (probability).
 
I am not arguing with your point that it is generally solvable. I will accept your word on that. However your statements about probability seem wrong to me.

> On your first guess you have a chance of 5/26 of matching at least one letter

If these were random strings of letters, picked without replacement, that would be the lowest p, right? For 1 letter guess vs. 1 letter word the chance of matching is 1/26, 2 letter guess vs. 1 letter word would be 2/26-1/(26^2) = 1/13.2549. I should be able to expand this to 5 letters, but I cannot be bothered, but it is not going to be 5/26. Is it Kyriakos's function? I am not sure without thinking a bit more than I want to right now.

However they are not picked without replacement. The second on my list is aalii, so only 3 distinct letters. If this was matched against a random string of 1 letter that would give you less than 3/26.
Your math here incorrectly assumes you're trying to match a full string of 5 random letters. This is an error.

I don't mean that you'll match the word in 4 guesses. I'm saying that in 4 guesses, you can attempt to match 20 out of 26 letters. There is no more math needed for what I am trying to say.

The first part of this puzzle is trying to figure out what letters you need to unscramble. When you can solve for position, that's even better. When you don't have all the letters, you can extrapolate from what you know are eliminated to figure out the word.

This is a word puzzle, not a mathematical one.
 
Since it isn't random strings, but real words, you'd have to calculate (boring) stuff including that (iirc) you can't have three consecutive vowels in an english word (edit: there is 'queue', but pretty rare). It will be boring to amass all the restrictions, but maybe some or most can amount to nothing, in practice. I doubt this is a game which would interest from a mathematical point of view, due to the restrictions from language as well as (apparently?) individual closed-system pool of words.
That is not the way I would do it, 'cos I am more a programmer than a mathematician. I would bootstrap it, ie. make a simple matching algorithm and get it to play the game a few hundred thousand times. Computer time is cheaper than my time ;)
Your math here incorrectly assumes you're trying to match a full string of 5 random letters. This is an error.

I don't mean that you'll match the word in 4 guesses. I'm saying that in 4 guesses, you can attempt to match 20 out of 26 letters. There is no more math needed for what I am trying to say.

The first part of this puzzle is trying to figure out what letters you need to unscramble. When you can solve for position, that's even better. When you don't have all the letters, you can extrapolate from what you know are eliminated to figure out the word.

This is a word puzzle, not a mathematical one.
I was purely commenting on the probabilities you quoted. Also, when you have maths everything is a maths problem ;)
 
That is not the way I would do it, 'cos I am more a programmer than a mathematician. I would bootstrap it, ie. make a simple matching algorithm and get it to play the game a few hundred thousand times. Computer time is cheaper than my time ;)

I was purely commenting on the probabilities you quoted. Also, when you have maths everything is a maths problem ;)

May seem like a bright idea, until the AI becomes sentient and attacks you ^_^
 
The mathematics involved here would be the commonality of letters appearing in words, to strategically arrange your guesses to have the most popular letters first.
 
Difference of scope, Wordle in practice very clearly isn't to be played with math in mind (and wouldn't always work if it did, either). But the difference in math thinking is between having a general sense of what is more probable, and knowing exactly how much more probable something is (as noted, in Wordle the latter won't really help in most cases, due to inherent limitations; while you can calculate exactly how likely it is to have letters x, in the specific game the calculation may not help much or at all, due to limited attempts).
 
In any word game, once you get practice at it, it makes sense to do the vowels first. From there it's usually not hard to figure out the rest of the word (this is why vowels aren't worth anything on Wheel of Fortune and why sometimes people blurt out funny answers - they're looking at word patterns and sometimes more than one set of letters fit... but the phrase comes out as nonsense or inappropriately funny).

Over on TrekBBS there's a group of us who play Star Trek Hangman. There's a trick to solving these, if they're not immediately obvious. Figure out the contractions, figure out the most common vowels, and that should give a good start to figuring out the phrase (these are phrases or bits of multi-person dialogue).

During the past couple of weeks the game has been going back and forth between me and another person while a couple of others guess letters.

Which dictionary is used for this Wordle thing?
 
Back
Top Bottom