> It seems like many of the variables are given names that are not descriptive at all to make it a bit more difficult to read.
The code is just minimized for prod..
The article as written makes it sound like the developer(s) intentionally wrote their code cryptically, whereas minimization for deployment is fairly standard practice
I just popped open DevTools on an SPA I made using create-react-app with default settings. Sure enough the minified production JavaScript uses shortened variable names. This is default configuration for Webpack, which is pretty widely used throughout (and outside) the React ecosystem.
Interestingly you can still view the unminified source, since create-react-app generates source maps by default.
It is pretty common. The goal of the minifier is to reduce the size of the file, so taking the function names, variable names, etc and making them as short as possible works towardd that goal
Closure Compiler (for JavaScript) does it. With the SIMPLE_OPTIMIZATIONS [0] flag, it will rename parameters for—and variables local to—functions to save space.
I've seen some minifiers that can restructure your code... replace if{} with a ternary ?: operator or use boolean shortcutting to replace the whole conditional with a ||, and so on. It's supposed to never do anything that actually affects the logic, but that sort of stuff scares me.
For some context, it didn't used to be terribly common. There's a fair amount of minifying that you can do without touching symbol names, though obviously it doesn't help as much as shortening them. The old jsmin cited about 50% reduction, and it didn't touch any variable or class names.
A word of warning for anyone inspecting the Wordle source code: the answers for each day are stored in a list ordered by day. If you search for today's answer, the next word in the list will be tomorrow's answer, etc. Be careful not to ruin the fun by seeing tomorrow's answer in advance!
You can also see the solution and various other points of pertinent data stored as a JSON string in your localStorage without having to dive into code.
I figured that was possible; from the UX it was pretty clear it’s all client side.
What I would find cool is derivation of the best strategy at any time. Just like blackjack, there should be a “best” move at all times , and it would be cool to measure yourself against that
I haven't implemented the best strategy at _all_ times, but this blog post[0] proposes a strategy (pick the word that minimizes the expected-size of the resultant set of possible answers). I made a User Script[1] that tells you how many words remain after each guess - it shouldn't be too hard to expand that to tell you a) what the expected answer-set-size was with your answer, and b) how that compares with the "best" answer.
I made one, not the optimal strategy though, I simply minimized the expected number of possible solutions for the next step. I repurposed my Mastermind solver since it's basically the same game. Just like Mastermind, minimax is probably better than what I did, but it does solve every Wordle in at most 5 guesses, on average 3.4 guesses.
Surely it differs from Mastermind (which I might not be remembering well as I didn't like it) in that the answers must be words in the game's dictionary rather than arbitrary colour codes? That seems to change tactics considerably.
I agree it changes the experience of playing the game for a human quite a bit, and you'll use different tactics, but for the kind of solver I made it doesn't change much - I had to change very little code to make it work.
From the perspective of the solver it just means the starting set of potential solutions is every word in the dictionary, instead of every permutation, but it doesn't really make much of a structural difference. Either way a solver can just brute-force its way through every potential solution since there aren't that many.
The other difference is that Mastermind tells you only how many of the pegs are correct, but not which ones. Wordle tells you which ones. That is easier, but it's counterbalanced by Wordle having a larger solution space. There's only 1296 possible solutions for classic Mastermind (4 pegs, 6 colors).
I think using the expected logarithm of the number of solutions (entropy) makes more sense from an information theory perspective. I wonder if it works better in practice.
It's not optimal at all, but works for every wordle word; it's built by finding the word (guess) that minimizes the maximum size of the possible words (to guess), a bit like Knuth Algorithm for Mastermind.
For an optimal strategy, a backtracking solution with pruning / maybe a branch and bound approach would work, but I didn't manage to implement a fast enough implementation for my small 8 threads CPU.
This is an unusual thing to find myself typing in a HN thread, but this could use a spoiler tag, as I did not expect to have tomorrow’s challenge ruined for me by a technical blog post.
I'm not easily finding the publication date, but for me the article says tomorrow's word is "query", which was actually the word a couple days ago. If that's what you see, too, then I think it's safe.
I believe the developer was interviewed and said he/she has no plans to change the game to make money. If you go to just https://www.powerlanguage.co.uk/ (maker of the game) you can see he made other games on Reddit (The Button and Place) and is listed as an artist, product manager, and engineer. I suspect the attention the game has received has resulted in many head hunters reaching out.
Think of Wordle as a loss leader for his career.
I made a little change that allowed setting the day's puzzle based on puzzle ID number via a query parameter so you could play previous day's puzzles. Here's the gist with relevant code block if anyone's curious: https://gist.github.com/antoniomika/5ec4741d309cc829a5bc26a5...
I rebuilt Wordle from scratch using the same word list. There are actually two word lists, one from which they select the answer, and another from which they validate real words. They are just arrays of strings hardcoded in the JS bundle.
When you submit a guess, it checks to see if your guess is in either array (or at least that's how I implemented it). And just does some relatively simple string comparison.
Your progress is just stored in local storage. You can blow your data away by deleting it via dev tools.
My version just lets you try again by refreshing, I'm not storing any data.
The viral factor of the original Wordle, IMO, is the share function and the little emoji grid it generates.
Came here just to post this too - My Motorola is now stuck in an endless loop of chrome crashes because it keeps trying to reload this blog and gets stuck every time, even trying to navigate away crashes chrome. Robert - next time you attack the source of a website, make sure the source of your own website runs properly first.
This was good while my wife and I were in the same time zone: we compared guesses and how we got there. Now that she's a day ahead, we can't do that right now (we found this out when she accidentally did a spoiler).
One thing I do while playing with people half a world away is to send just the final pattern (Share button copies that to the clipboard). Once both parties have sent their answers, you can share the screenshots :-)
Fun times. I remember back in the year 2000, during the dot com craze, there was a company in India that built a clone of "Who wants to be a millionaire". It was in beta and there was no real cash or prize involved.
They had all the answers stored in the source code. I wrote up a quick perl script to play the game and unfortunately left it running overnight, and in the morning there were complaints from other players asking how I'd reached the top rank so quickly.
I guess I wasn't the only person who tried to reverse engineer wordle because they were stuck on the final try.
I thought I would do a programmatic soltion because that was the only win I will be able to get. I did find it interesting that they had all the 5 letter words in the frontend logic.
The code is just minimized for prod..
The article as written makes it sound like the developer(s) intentionally wrote their code cryptically, whereas minimization for deployment is fairly standard practice