Optimizing Wordle guesses

Published: Jan 17, 2022 by Steve Baskauf

I’ve recently started playing the viral word game “Wordle”. After numerous discussions among family members about guessing strategy, I decided to spend some time over the holiday weekend writing a Python script to play with different guessing algorithms and strategies.

The details are in a blog post, but if you don’t like reading text and just want to start playing with the code, you can go straight to this Colab notebook to run and hack the code yourself.

The TLDR summary of the blog post is:

  1. I generated a list of five-letter English words of a similar size to what is used in the game.
  2. I created a Wordle_list object that screens word lists based on “guess codes” (an alphanumeric version of the colored squares that the app shows you after you guess).
  3. I messed around with different ways to use letter frequencies in the words to assign scores to words in a list based on estimating how effective the words would be at screening out the other words.
  4. I wrote some code to generate the most effective words to use as automatic first two guesses (spoiler alert). They are “arose” and “glint”.
  5. I used existing Wordle game words to test whether it was more effective to just use these two words, or to let the scoring system chose the second word. It didn’t make much difference.

Enjoy!

Share

Latest Posts

Uploading a thousand Gallery images to Commons
Uploading a thousand Gallery images to Commons

I recently finished work on CommonsTool, a Python script to upload artwork images to Wikimedia Commons. In addition to uploading the image files, it creates Structured Data on Commons claims to provide machine-readable metadata about the images and to link them to Wikidata items that describe the underlying artwork objects. It also uploads the images to the Vanderbilt Libraries’ International Image Interoperability Framework (IIIF) server and generates IIIF manifests to display those images in a IIIF viewer.

Making SPARQL queries to Wikidata using Python
Making SPARQL queries to Wikidata using Python

I recently solved several annoying problems that I’d been having when using SPARQL queries to acquire data from Wikidata. My success inspired me to write a comprehensive Python class that will reliably carry out every kind of SPARQL Query and Update, with defaults to easily make SELECT queries to Wikidata.

Birding in Puerto Rico
Birding in Puerto Rico

After recently making a trip to Puerto Rico that was primarily focused on bird watching, I decided to write a blog post to pass on some of what we learned. Much of the information that we got from books or the Internet was outdated or incorrect, so hopefully this post will help others to have an easier time finding good places to bird there.