Christian Genco Profile picture
Founder of https://t.co/8J3kwMY33n. Working on https://t.co/I0UUYmEmEV. Watch/listen to my weekly updates at https://t.co/YW8MYcNbf0 and check out other projects at https://t.co/VO8tGs34Ei

Jan 6, 2022, 17 tweets

Well this seems like a solvable problem.

Wordle 201 4/6

β¬›β¬›πŸŸ¨β¬›β¬›
⬛⬛⬛⬛⬛
πŸŸ©β¬›β¬›πŸŸ¨β¬›
🟩🟩🟩🟩🟩

First step to a general solution: come up with a notation for storing the feedback I get from the game.

These two screenshots are, for my purposes, the same set of information.

Next, let's write a way to evaluate each guess given a known solution that returns data in this format.

Now we need a way to filter possible words given a set of guess results.

ie: given my record of previous guesses, which words could the actual word possibly be?

With the above code in place solving every Wordle is pretty straightforward!

First `filterPossibilities` to get the array of possible solutions from your past guess results.

Then guess the most helpful next guess (the guess that minimizes the maximum remaining possibilities).

Although correct, this solution is *very* slow.

To speed it up, I can 1) make the algorithm multithreaded so it runs on each of my M1 Max's 10 cores, and 2) give up early on words that aren't going to beat my best case.

Let's try #2 first...

Oops that's not right

Heyyyyy there we go.

Turns out the best first word to guess in Wordle is "serai" ("In Eastern countries, an inclosed place for the accommodation of travelers").

No matter what the actual word is guessing "serai" willβ€”at worstβ€”leave you with only 697 remaining possibilities.

OH WHAT'S THIS looks like it's my favorite part of making stuff: scrape together just enough justification to buy *another* domain name πŸ₯³

Next steps:

- [ ] compute the tree of guesses to every word
- [ ] throw together a React app
- [ ] deploy

Movin' right along.

I decided against precomputing the tree of guesses since 1) now it runs reasonably quickly and 2) if I compute on the client side there's more flexibility (ex: "I've already made these three suboptimal guesses please tell me the next best guess").

- [x] dark mode (critical)

Well would ya look at thatβ€”it's our old friend `guessResults`!

This time with a GUI 😎

Next I need to figure out input. I guess I'll just copy Wordle's virtual keyboard.

Then I need to connect the solver with the GUI which should be straightforward. Some UI to figure out.

Got a little sidetracked hunting for React animation libraries that I didn't hate and then making my own powered by animate.style

Now I can do:

<Animate render={({headShake}) => <input onChange={headShake} />} />

We're almost functional!

ALRIGHT we've got an actual usable product (spoilers for today's puzzle in the demo).

Wordle 202 4/6

πŸŸ©β¬›β¬›β¬›β¬›
πŸŸ¨β¬›β¬›β¬›πŸŸ¨
β¬›β¬›πŸŸ©β¬›β¬›
🟩🟩🟩🟩🟩

Time to deploy this baby and then maybe add @NathanG's github.com/leonardodino/r… input and make the top buttons actually do something.

It's unreasonably easy to deploy React apps on @vercel.

πŸ‘‹πŸ» Hey @powerlanguish I solved your game: wordlesolver.com

OH I'VE MADE A CRITICAL MISTAKE

There are actually *five* optimal guesses (each guess will, at worst, narrow down the possible list of words to only 168).

I didn't realize the Wordle wordlist was split into "possible answers" and "acceptable dictionary word guesses."

Share this Scrolly Tale with your friends.

A Scrolly Tale is a new way to read Twitter threads with a more visually immersive experience.
Discover more beautiful Scrolly Tales like this.

Keep scrolling