A few months ago, at my old job, my boss introduced me to 24-puzzles. It’s a simple arithmetic game: you’re given four positive integers, and the goal is to combine them using ordinary arithmetic operations to produce 24. For example, one might be given [1,2,5,8]. One can then subtract 5-1=4, subtract 8-2 = 6, and then multiply 4×6=24. Or you might have [2,3,5,6], and solve it by 5×6-2×3. Some harder ones, like [1,5,5,5] are excellent nerd sniping fodder.
Sometimes there are multiple ways to solve a 24-puzzle. Going back to the earlier example of [1,2,5,8], instead of doing (5-1)×(8-2), we could have done (8-2)×(5-1). But that really feels like basically the same thing, doesn’t it? We’ve just changed the order of the multiplication. It’s still the same solution, just massaged a bit. But consider instead 1×8×(5-2). That’s also 24, but this solution feels more genuinely different. Now there are two multiplications instead of just one.
It’s not always clear-cut, either. Take something like 6×5 – (7–1) as opposed to 6 × 5 + 1 – 7. Are these different? One solution has an addition and the other has two subtractions so it seems like it should be different, but if you distribute the – over the parentheses, you get the same thing. Are these two solutions fundamentally different, or no?
The answer is that it depends. It’s a matter of opinion, and of definition. Whether two solutions to a given 24-puzzle are distinct depends on what you consider to be distinct. Maybe (5-1)×(8-2) and (8-2)(5-1) are distinct solutions because the order of the multiplication changed, and maybe 1×8×(5-2) isn’t distinct because it still evaluates to 24. Math isn’t about what’s fundamentally, unequivocally true. It’s about what follows from the assumptions and definitions we decide at the beginning.
But this would be a very short and rather boring article if I left it there. So instead, let’s come up with a definition for two solutions being equivalent. Toward this end, I’m going to introduce polynomials.
Formally, a polynomial is a finite expression with some variables that just uses addition, subtraction, multiplication, and positive integer exponents. That definition is a bit unwieldy, so we’ll unpack it bit by bit.
We want polynomials to be finite – that just means there’s a finite number of terms. Infinite polynomials are called power series, and they’re neat, but we won’t need them today.
Variables, in this context, are just symbols that we can do operations to. In a high-school algebra class, variables are usually thought to represent numbers – in an equation like 4x+2=10, we want to find out what number x is (left as an exercise to the reader). In general though, we don’t need x, y, a, n, or any other letter to represent a number at all. All we require is that we can add or multiply it to number or other variables, or whatever else. Of course, we can plug in specific values to the variables later, either to get new polynomials with fewer variables or to simplify into just a number, but that’s not necessary.
Hopefully you know what addition, subtraction, and multiplication are. It’s important to note that we do not allow division though – at least not yet. Exponents are also fine, but they need to be positive integers. If we have x as a variable, x² is allowed, but x⁻² is not. We also can’t raise variables to the power of variables – only to positive integers. Really, the only operations allowed are addition and multiplication (subtraction is just spicy addition), since you can write any positive integer exponent out just with repeated multiplication.
For a few examples: x²+2x-1, y³-8x, a²b+2ab²-b³ are all polynomials. x/y, 6c+aᵇ, 1+x+x²+x³+… are all not polynomials.
Polynomials have some useful nomenclature. A “term” is a number and some variables all multiplied together, with no addition. ab²x and 7x³y² are both terms, but 8(x-y) is not. Every polynomial can be written as the sum of finitely many terms. The degree of a term is the number of variables that multiply together in it, counting exponents. So -12a²b would have degree 3, since there are two a’s plus one b. The degree of a polynomial is the largest degree among its terms.
Polynomials are, in some sense, the most basic structure you can build out of addition and multiplication. And since that’s what they’re made of, we can add and multiply them too, in the obvious way. (x²+2x-1) + (y³-8x) = x² + 2x – 1 + y³ – 8x = x² – 6x – 1 + y³, if we combine like terms. Multiplication is straightforward as well, we just use the distributive property.
\((y^3 – 8x) \cdot (a^2b + 2ab^2 – b^3) = a^2by^3 + 2ab^2y^3 – b^3y^3 – 8a^2bx – 16ab^2x + 8b^3x\)
Note that I’ve ordered the variables in each term in alphabetical order. It doesn’t matter what order they’re written in since multiplication is commutative, so it’s useful to have a convention.
There’s a lot that can be said about polynomials. Enough to fill a textbook. Indeed, enough to fill several textbooks. Indeed, enough to potentially fill an entire successful and fulfilling career as a mathematician. But that’s not quite what we’re here to do today – we’re here to decide what solutions to 24-puzzles do and don’t count as distinct, and we know enough about them to engage with that.
Let’s go back to the first example of a 24-puzzle; [1,2,5,8]. We had two solutions that felt like they should be the same (5-1)×(8-2) and (8-2)×(5-1). How can we make that intuition precise? By using polynomials.
Instead of using the numbers 1,2,5,8, let’s give ourselves four variables: a,b,c,d, and do the same thing. The first solution has us adding the first two and last two numbers, and multiplying the results. Doing that with our variables, that’s (a-b)(c-d)= a×c – a×d – b×c + b×d. Notice here that the variables in the terms are in alphabetical order, and the terms collectively are as well. In the second, we swapped the order around a bit; (c-d)(a-b) = c×a-c×b-d×a+d×b. This looks different, but if we put everything in alphabetical order again, we get a×c – a×d – b×c + b×d.. It turns out, these two solutions actually come from the exact same polynomial. For that reason, I claim that they are the same solution.
But remember then our other solution: (4-1)×8×1. If we replace numbers with variables, this time we get (c-a)×d×a = a×c×d – a²×d. This time, the polynomial is fundamentally different – the first one had four terms of degree 2, whereas this one has two terms of degree three. Since the polynomials have different degrees, they must be different, so these solutions are inequivalent.
This definition also answers our gray area question: 6×5-(7-1) vs 6×5-7+1. Replacing 1,5,6,7 with a,b,c,d respectively, both solutions have the same polynomial: a+b×c-d, so they’re the same. But of course, you’re welcome to disagree. I like my definition, but it’s not perfect.
For one, 24-puzzles allow for division, but if you’re working with polynomials, you generally can’t divide by variables. This isn’t too big of an issue - if you let yourself divide by variables or indeed general polynomials, then you get a related structure called a rational expression or rational function, which is basically just a fraction with polynomials instead of numbers.
There is a more fundamental problem though. Keeping with my favorite example [1,2,5,8], we’ve found 1×8×(5-2), with its polynomial -acd + adb. But what about, say, 8×(1×5-2) which has d(ac-b) = acd – bd. These are different polynomials – one has two terms of degree 3, the other only has one of degree three and one of degree two. But to change from one solution to the other, all I did was move a multiplication by 1. I could do that again, and get 8×(5-1×2) which has another polynomial d(c-ab) = -abd + cd, yet a third distinct polynomial. Should these solutions be considered distinct?
Of course, there’s no one right answer. I’d be inclined to say no – if someone told me they found three different ways to solve this puzzle and the only difference was what the multiplied by one, I would probably roll my eyes. So maybe this polynomial technique is insufficient. It can tell us that two solutions are definitely the same, but not that they’re definitely different.
But that’s just what it’s like to do math. You have a problem to solve, so you find a tool that helps you. Sometimes it’s exactly what you need, sometimes it’s pretty close but you still need just a little sometime extra to finish it, and sometimes it’s a complete dead-end.
And then sometimes, by playing around with a tool for long enough, it can give you even more fun and interesting problems to solve. I’ve been thinking about distinct 24-puzzle solutions for a while now, and as I write this, I’m working on how many different polynomial shapes can be made not just out of 4 variables, but any particular number of variables. If I ever figure that out, I’ll write a follow-up article
No posts

Comments
Nothing yet. Say the first thing.
Sign in to join the conversation.