Equationle (you know, like Wordle, but for Equations)

  • 2022-04-07

Earlier this year, when the game Wordle was all the craze, I woke up one morning with the idea in my head of the same basic game, but instead of choosing letters to make a word, the objective would be to pick numbers and operations (addition, subtraction, multiplication, division) to complete an equation.

The result is online at http://equationle.com. It’s nothing polished or complicated or great in any way, but, I had fun building it, and I get a little bit of fun from playing it.

I decided to make the equation* consist of 3 numbers and 2 operators that the player must figure out, which would be shown to equal a pre-determined number. To make things a little more constrained, I thought to put parentheses around the first 2 numbers, so you wouldn’t have to worry about order of operations (e.g., doing multiplication before addition) – the parentheses would mean to always do the left operation before the right one.

For example (as shown in the screenshot):

(number operator number) operator number = 21

Just like in Wordle, a correct guess is shown in green, and a guess that’s in the equation, just not the right place, is yellow. Incorrect guesses are shown on the on-screen keyboard in dark-gray. You can enter an equation which doesn’t equal the number shown – if so, that line will switch from showing an = to a ≠ sign. Oh, and unlike Wordle, every time you reload the page you get a new game (and I didn’t build the result-sharing feature…).

Before I put together the user interface for the game, I first wrote a little program to generate all possible equations fitting that structure, and to work out their result. Then, so that the game would never pick an equation that only had 1 or 2 possible combination of inputs to produce the answer, I counted (well, my program counted) how many equations each produced every given answer, and then only kept ones that had more than 10 equations.

Finally I placed that list of equations into a JSON data structure that I loaded into the HTML/JavaScript user interface that I put together, and I did my best to copy the CSS styles used on the real Wordle. After buying a domain at hover.com and uploading to Linode, I was all set.

* Technically, I suppose, since we’re only building the “left hand side” of an equation, I should call it an “expression”, but, this isn’t a formal paper or anything, so let’s just go with this loose language.