Categories
wordle

Solving Wordle Game using Information Theory and Entropy

Wordle is a web-based word game developed by Josh Wardle.

Players have six attempts to guess a five-letter word; feedback is given for each guess, in the form of colored tiles, indicating when letters match or occupy the correct position.

The mechanics are nearly identical to the 1955 pen-and-paper game Jotto and the US television gameshow Lingo.

Wordle has a single daily solution, with all players attempting to guess the same word.

Solving Wordle using information theory

what is Wardle ?

Wardle initially created the game for himself and his partner to play, eventually making it public in October 2021.

The game gained a large amount of popularity in December 2021 after Wardle added the ability for players to copy their daily results as emoji squares, which were widely shared on Twitter. Many clones and variations of the game were also created, as were versions in languages besides English.

The game was purchased by The New York Times Company in January 2022 for an undisclosed seven-figure sum, with plans to initially keep it free for all players.

How do you play Wordle?

The game was developed by Wardle, a Brooklyn software engineer, who told The New York Times he created it for his partner, who loves word games.

The concept is similar to the guess-the-color game Mastermind. Wordle is a grid of five squares across and six squares down. Each horizontal row of five squares represents an opportunity to guess the random, five-letter word of the day. With six rows, players have six opportunities to guess.

With each guess, the game will let you know which letters you have right. The background of a letter turns green if it is in the word and in the correct spot or yellow if it’s contained in the word, but in the wrong spot. Those that are not contained in the word are dark gray.

Each guess, and each correct letter, gets you closer to finding the word of the day. And it can get tricky — sometimes letters are used more than once. The goal is to guess the word in as few tries as possible, and before you run out of attempts.

Everyone has their own strategies and you can google lots of suggestions for improving your chances of guessing the daily word. Some people use the same starting word every day. Others try to focus on words with lots of vowels to zero in on which are used in the word and which are not. But Bellos says a good idea is to start with words that contain some of the most common letters in the alphabet.

Part of the game’s appeal is that it’s very “achievable,” Bellos says.

“Even if you think you’re not good at words, at logic, or not good at puzzles, you’ve got a pretty good chance of getting that word in six goes,” he says. “No one likes puzzles that are too hard or too easy, but Wordle is just about right.”

Differential Entropy to Solve Wordle

This time we’re talking about Wordle, the game that’s taken the internet by storm for the past ten days. You have six attempts to guess a five-letter word.

In each guess, for each letter, you’re told whether the letter doesn’t show up in the word (it comes up grey), whether it shows up but not where you said it did (yellow), or if you got the letter and the position both right (green). Here’s one I did last week.

Solving Wordle

In this case, the solution space is known, and what’s limited is our ability to explore it, so this is a game of being maximally efficient with the little space we have. You can tell in the above example that I wasn’t perfectly efficient: I guessed “miles” after “vibes” even though I knew the “e” and “s” weren’t there, and I guessed “sidle” after finding out there wasn’t an “L” anywhere. I took six guesses to get this one, but I could’ve done it in fewer. How do I know this for sure? To answer that, we’ll take a quick dive into information theory, and the central concept of entropy.

Information theory is a branch of electrical engineering/computer science that deals with efficient ways to handle information: how to figure out how much information is in a certain amount of data, how to send or receive information efficiently and without being vulnerable to errors, and how to place fundamental limits on the sorts of problems we’re dealing with here. For this solver, I’ll use the most essential tool in information theory: entropy.
Entropy

Entropy is a concept that expresses how much uncertainty there is in something we don’t perfectly know. A simpler example of when we use this is in a number guessing game. Suppose I think of a number between 1 and 100, and ask you to guess it: after each of your guesses, I’ll tell you if you guessed too high, too low, or exactly right.

Your job is to take the minimum number of guesses you can and get the number right.

Let’s play now!

36? Too low.

83? Too high.

42? Too low.

79? Too high.

56? Too low.

66? Too low.

73? Too low.

76? Too high.

75? That’s it!

You can see this wasn’t very efficient – we spent a lot of time dancing around the actual number, and we only really got a good sense of what it was near the end. For most of the middle, the range of numbers it could’ve been was really high, and you might get the idea that with a smarter guessing strategy, you could’ve made that range smaller in a lot less time.

The best algorithm for Wordle

Let’s start thinking about how this framework could be applied to Wordle.

When you make a guess, there’s 243 possible results: the three outcomes of (grey, yellow, green) to the power 5 because it’s possible independently for each letter.

Of the 2315 possible answers in Wordle, a fixed guess will result in one of these 243 results, so our first guess will partition the search space and pick one of those 243 buckets. If we happen to get the “all green” bucket, we’re immediately done, but we’ll almost certainly land up in one of the other buckets.

One of the coolest things about programming is when you see emergent behaviour that matches what you would intuitively expect, or that you can put human reasoning to. It’s the aspect I like the most about computational science: like any bit of mathematics, it gives you new qualitative insights that even sitting down with a calculator, a log table, and a lot of patience wouldn’t be able to do. I really like this extract from Lockhart’s Lament, a great essay on the problems with K-12 mathematics education:

The reason I enjoyed making this is, well, a little bit for the Twitter clout, but mostly because it turned out to be a fascinatingly intricate problem. I didn’t tell it much about what it was doing, but it managed to talk back and tell me a great deal.

Can you play past Wordle puzzles?

you can play previous days’ Wordle challenges, just not the straight way though. Wordle is an online game that is accessible to anyone with the internet from any part of the world. As a web-based game, all you have to do is go to the host website to take the daily challenge.

Where do I get Wordle game?

The game does not require an app. You simply go to powerlanguage.co.uk/wordle in any web browser, whether that’s on a desktop or a mobile device. The game challenges you to guess a daily five-letter word in six tries. You can start each day’s game by typing any five-letter word.

What does entropy mean in math?

The idea of entropy provides a mathematical way to encode the intuitive notion of which processes are impossible, even though they would not violate the fundamental law of conservation of energy.

Also read :