Codehead's Corner
Random ramblings on hacking, coding, fighting with infrastructure and general tech
Hacking Around with Wordle
Posted: 28 Jan 2022 at 19:37 by Codehead

Intro

The year is 2022 and EVERYONE is playing Wordle.

Wordle is a fun little word game that anyone can pick up and play. Six guesses to find a five letter word. It is surprisingly addictive.

However, after solving the daily puzzle I found I had to wait 24 hours for the next one. Like any self respecting hacker I wasn’t having that so I smashed F12 to have a dig around in the guts of the game.

Digging Through The Code

Wordle’s source code is pretty compact. The index page is a bunch of inline CSS and a few JavaScript files. The bulk of the work is done by the JavaScript in main.e65ce0a5.js. The code is minified, but the browser’s developer tools can easily fix that and expand it out to something more readable.

While scrolling through the JS, I stumbled on two huge string arrays:

La = ["cigar", "rebut", "sissy", "humph", "awake", "blush", "focal", "evade", "naval", "serve", "heath", "dwarf", ... ];
Ta = ["aahed", "aalii", "aargh", "aarti", "abaca", "abaci", "abacs", "abaft", "abaka", "abamp", "aband", "abash", ... ];

The ‘La’ and ‘Ta’ names are irrelevant as they have been mangled by the minifier. However, a quick Ctrl+F search for the word of the day ‘CRANK’ (Jan 8th, Wordle #203) shows that the word appears in the ‘La’ array.

The array contains 2315 words and ‘CRANK’ is the 203rd entry. So we can assume that this is a list of the answers. Stored in sequence. In plaintext.

image

I guess the game was originally written as a personal project that was never meant to get the exposure that it has gained recently, but even a simple Base64 encode or fixed key XOR would have been enough to keep the answers away from the most basic examination.

The second array contains 10657 words. This looks like a list of valid words that Wordle will accept as guesses. There are some pretty weird words in there which I don’t recognise. I guess that’s why I suck at Scrabble.

So What Can We Do With The Answer Data?

OK, so after getting over the ease of breaking the game, what’s next?

It’s pretty easy to look up any answer for a given day. If the solution for Jan 8, 2022 is index 203 in the array, we can calculate that index 0 must correspond to Jun 19, 2021, that’ll be the date the game launched. To calculate the solution for any given day, we just need to take the difference between the target date and Jun 19, 2021 to find the offset of the solution.

I’ve knocked up a quick demo that will give the solution for today and tomorrow HERE.

We can also work out that Wordle will run out of words 2315 days after the start date. That’ll be Oct 21, 2027. Mark that in your calendar as a bad day for the Internet.

More Analysis

For those who still want to play the game and don’t just want to look up the answer, there have been a bunch of articles around the Internet about the best starting word for Wordle. People try to hit as many vowels as possible with the first word or rule out less frequently used letters.

As we have all the words Wordle will accept and the list of all possible solutions, we can do some statistical crunching to work out the best starting words. I’ve documented my analysis of the data over on the Wordle Analysis page.

Categories: Hacking Hacks



Site powered by Hugo.
Polymer theme by pdevty, tweaked by Codehead