Wolfram Computation Meets Knowledge

Wordle the Wolfram Way

Wordle the Wolfram Way

The free online game Wordle has come at a time when each of us needs a simple, friendly challenge to take our minds off other worldly issues.

Josh Wardle created Wordle for his partner and then shared it with the world in October 2021. Then, news broke on January 31, 2022, that he had sold the application to the New York Times, who, it is expected, will eventually put it behind a paywall.

The concept is simple and engaging: you are challenged to guess a five-letter word in six guesses. Here are the rules from the Wordle website:

How to play Wordle

Posting only one new Wordle challenge a day is a sensible design choice—it gives you a new game once a day and protects you from any tendencies you might have to get stuck playing it over and over and over…

(That’s the idea at least.)

The Challenge of a Slow Weekend

In early January, I was texting with my daughter, who had introduced me to Wordle a few days earlier:

First text message

My colleagues and I at Wolfram Solutions build some pretty large and complex user interfaces for our customers. (A recent one came to about 25 thousand lines of Wolfram Language code just for the user interface portion alone.) So I am pretty confident when it comes to putting together a UI quickly. I decided to take up the challenge in order to keep myself busy during that slow weekend.

A few hours later, I texted my daughter back with an initial version:

Second text message

As you can see, I am a bit spelling-challenged. (This figures later in the story, along with the fact that my daughter is a speech pathologist….)

Now, in creating this, right away I violated the sacrosanct principle of “only one Wordle a day.” All I can hope is that anyone who gets hooked on this will forgive me.

I wrote a post at Wolfram Community to share the code with others, and also so that they could play with the code as well as the application itself. (You can read the full code and download the package from that post, as well as see some other folks’ comments.) It’s also an example of one way to design and code a Wolfram Language package.

Over the next week, I spent a little time tweaking the application to let the user choose which part of speech the word is restricted to, as well as to give them the choice of whether the length of the word is 4, 5, 6 or 7 characters long.

MWordle interface

(In the original version of this GIF on Wolfram Community, the application had “speech” misspelled as “speach”; given that my daughter is a speech pathologist, I should have known better! And it’s not her fault that she didn’t tell me of the error because I hadn’t yet given her the updated version.)

These additional bits of functionality, as compared to the original Wordle, are out of line with the (brilliant) simplicity of its design. But it makes the point that both the algorithmic and user interface capabilities of the Wolfram Language let you explore variations and approaches to your heart’s content.

The MWordle.m package comes to a bit more than four hundred lines of Wolfram Language code. The JavaScript code of the web version is quite a bit more than this, but to be fair, it has more functionality than the Wolfram Language facsimile that I wrote. Using the Wolfram Language’s vast resources, you can customize, revise and debug versions ad infinitum and very efficiently. Though it was a slow weekend, after I created the first version of this, I still had plenty of time to do my laundry and catch up on Netflix, then come back to tweak the code.

And More…

Aside from creating the facsimile, interesting questions come up about strategies for playing the Wordle game. As expected, there is much chatter on the internet about this. What are the best words to use when making your first guess? How can you optimize subsequent guesses? And so on and so on….

Arnoud Buzing quickly created a ResourceObject that contains the actual word list that the web version of Wordle uses. (My code uses Mathematica’s dictionary through the WordData function.)

While I personally prefer to leave a patina of mystery to playing the game and approach the online version as if I were an algorithmically naive person, it’s incredibly straightforward to explore it with the Wolfram Language. Like many other things, a simple game like Wordle can be viewed as a starting point for exploring a particular computational world.

Here are some examples. Someone in my Wolfram Community post said, “I was thinking it would be good to compute what the best starting word would be for Wordle based on WordData, letter frequencies and letter position frequencies.”

So I took up the challenge and wrote the following as an example of one possible starting point—initially without taking into account the positions of the letters.

Here are all the five-letter words used in the application:

$fiveLetterWords = Module

There are 7,517 of them:


Here is the ordering of the frequency of English letters for these five-letter words:

$orderedLetters = Keys

So, let’s see if there are any words among the list of these five-letter words that match the highest five of the frequency-sorted letters (and requiring that there be no repeated letters in the word):

StringJoin /@ Select

Wow, there’s only one! And it takes care of another possible approach—try to have as many vowels as possible.

Let’s relax the constraint slightly and pull things from the highest nLetters characters in the frequency-ordered list, but still make sure that there are no repeating letters:


From the top five letters, as before:


From the top six letters:


From the top seven letters:


Arnoud also wrote a post about an approach to optimizing the guesses that you might make as you work through a Wordle challenge. In it, he takes into account the letter frequencies based on the positions of letters in the word.

Peter Barendse suggested that code like the sort I have in the MWordle application could be used to train an intelligent agent to play Wordle. That’d be fun to do.

The possibilities are endless, and the Wolfram Language is the ideal vehicle for exploring the computational world of Wordle.

Visit Wolfram Community or the Wolfram Function Repository to embark on your own computational adventures!


Join the discussion

!Please enter your comment (at least 5 characters).

!Please enter your name.

!Please enter a valid email address.


  1. Fun! I wrote some code in Wolfram Language about a week ago to compute the optimal first, second, third (etc) words to use. Obviously beyond the first word, the optimal next word(s) depend on the feedback you get back, but I still found it interesting to know what the best words to use would be if you were to go without any feedback.

    Using 5 letter words with a word frequency of at least 1-in-3-million, I determined those to be:


    I find it fun that words like “DEBUG” and “VOWEL” would show up here. Fitting!