Started from the bottom... and well we're here

Python | Wordle Start Word Ranker

Project Website | GitHub

I’m a little behind the curve, now that Wordle has been bought out by The New York Times. They immediately let us know they would be placing it behind a paywall, but there are literally dozens of us with Wordle clones ready to be of use

My project started with a discussion with my Dad. He tells me “stare” is a fantastic word to start with. He goes on about the vowels and common letters. I drop a far less appropriate word as a starter and assert surely my word is better!

I had no way of proving either way, but then I realized. I know how to program and I had been putting effort into learning Python at a more fundamental level for an upcoming job interview. I realized, this is a great showcase project.

While I knew my potential new job utilized Flask, I decided to go with FastAPI on the recommendation of a few Python developers I knew. It was the hip new framework and borrowed the same principles as Flask so I gave it a go.

It’s fairly standard in terms of setting up a route, it supports rendering HTML directly and even includes Swagger-UI for API documentation built right in.

I filtered through a few iterations of wordlist formats and finally found the actual wordlist Wordle uses. I settled on using sets, as a way to ensure the data was unique and I was looping through the entire item list so it didn’t really matter how I stored them. Since I had already created methods to import a raw list or a CSV, I decided to keep those abilities for later down the road when I wanted to make my own custom Wordle game.

Next I created a class for managing the guess attempts. It would store the wordlist and provide a way check a word against the wordlist for efficiency or compare 2 words together to see which was superior. That was after all, the purpose for writing the program. I had to prove my Dad wrong.

I hadn’t looked at Wordles source code at this point, I wanted to figure out everything from the ground up. The method used to check a word as a guess was fairly straight forwarded. Was the value at a specific index in the guess the same as the value in the selected word at that index? No? Is it at least in the word somewhere? No? Then it’s not anywhere and gray tile it.

This method worked fairly well and resulted in a list of guess attempts, all averaged down to a handy percentage. How likely you were to get a green, yellow, and gray tile with any given word. It was a little confusing from an outsiders point of view, so I added everyones favorite ranking method.

The “Whose Line Is It Anyway” method.
If you get a green tile, it’s worth 2 points, yellow tile is 1, gray tile is 0. Average them together and you generally get a number between 1 and 3. The higher the number the better, but is it really scientific? Remember, the lines are made up and the points don’t matter.

After the underlying mechanics were working, I had to attach the guess class to the actual API so I could work with it outside of my own computer. I setup a few endpoints for a single word versus comparing them and even setup a highscore function to keep track of the best found words. In the past I had used Bootstrap to stand up a simple website UI, exactly like I was doing.

I’m unsure where Bootstrap went wrong, but I miss Bootstrap 3. It made sense, had a simple grid system and panels. I loved the look of panels, now I just have accordions.. and they misbehave across browers if you want them static.. anyway, I cobbled together enough of a UI and presented it to my Dad.

Unfortunately… “stare” was way better than the vulgar word I came up with. It sparked interest in my Dad, who at this point became a preacher of Wordle and his son’s websites. Within a few hours of showing it to my Dad, I had 10’s of hits on my test docker container. I had been running the program from my VSCode while I worked on it, and my Dad had decided we’re in production!

I quickly finished the error handling (as of writing they are still javascript alert boxes) and built a docker container utilizing my GitLab CI/CD. Created a few test cases for the API and had a full image I could deploy.

I run a Portainer instance that helps me maintain my internal docker hosts, it was trivial to connect Portainer to my GitLab container registry and load the image onto my main “just for fun” host.

I’m working on a second iteration that allows you to upload a custom Wordle list and create your own Wordle game to play amongst your friends and family. With NYT buying up Wordle, I’m sure a free alternative will be welcomed by the community.