### Video Transcript

In this video, we’re going to learn about cryptarithmetic puzzles. Some people call them cryptarithms or alphametics. But they’re a type of puzzle which involves thinking critically about alphabetic characters in arithmetic calculations. It’s generally thought that cryptarithmetic was invented a long time ago in China and called letter arithmetic or verbal arithmetic. Many similar puzzles also appeared in India during the Middle Ages, with calculations being presented with many missing digits represented by dots. And the challenge was to find the missing digits.

For example, in this division puzzle, all the digits except sevens have been replaced by dots. And you have to fill in all the blanks. And there’s only one unique solution that works. So that’s quite tricky. Now, a bit of a refinement to this type of puzzle was to put different symbols or letters to represent each unique digit in the calculation. For example, this one here, ABC times DE. And then we’ve got the calculation below it. In this form, each letter represents a digit. And we know, for example, wherever we see the letter C, it will always be replacing the same digit in this particular puzzle.

Another development was to pick the letters carefully so that they spelt words. And ideally, they had some kind of relationship to each other as they were written. A great example of this was the puzzle set by Henry Dewdney in Strand Magazine in 1924, SEND plus MORE equals MONEY. The back story was that it was a telegram sent by a son to his parents when he run out of money at college. Now, this is the sort of puzzle that we’re gonna talk about. And as well as restricting ourselves to puzzles that have apparently meaningful words in them, there’re a few extra rules that also apply to this sort of cryptarithmetic. Each letter corresponds consistently to a different digit from zero to nine.

So for example, S could represent five, M could represent one, and so on. But it wouldn’t be allowed to have the same digit represented by two different letters. So we couldn’t have both S and M representing the digit one. Each letter is always used to represent the same digit in the puzzle. For example, E appears three times in this puzzle and must represent the same digit in each case. No number in the puzzle is allowed to have a leading zero. So neither S nor M here could represent the digit zero. We’re also only gonna talk about addition of two numbers. You can make puzzles with more than two numbers added together. Or you can rearrange them to make a subtraction calculation. But we’re not gonna consider that.

To be strict about it, we’ll also consider a proper cryptarithmetic puzzle to have just one unique solution, although some puzzle writers don’t enforce this rule. The process of solving cryptarithms isn’t a matter of just following a simple formula. It requires a bit of reasoning, some trial and error, and a lot of perseverance. Let’s go through and solve the SEND plus MORE equals MONEY problem together to see how it could be done. There are other ways. But hopefully the techniques we talk about will help you to solve your puzzles.

Of course, if you can write a bit of computer code, then it’s pretty straightforward to put together a simple program that tries out all the possibilities to find the right one. I wrote this one in Python and deliberately made it run through every possibility without trying to make it more efficient, just to see how long it took — just under two minutes by the way, although my equivalent QB64 version took just 0.7 seconds. For example, I didn’t eliminate S equal zero and M equal zero for my inquiries, which meant it came out with 24 unacceptable answers in which M was equal to zero. I also didn’t make any other efficiencies such as realizing that M must be equal to one because you can’t carry more than one when adding two numbers, but more of that later. Then with the letters S, E, N, D, M, O, R, and Y, each having 10 possible values, zero to nine, that makes a total of 10 to the power of eight combinations to try, a 100 million combinations. Imagine taking that approach by hand, it would take forever.

Anyway, now let’s go through a few things that you can check to help you solve this puzzle manually. First thing, make a list of all the unique letters in your puzzle. We can make a table of their possible values from zero to nine and cross them off as we eliminate all the possibilities. For example, we said none of the leading digits can be zero. So S and M can’t be zero. So we can cross them off. Now, there are some other quick ways to cross off a few numbers. For example, if we had something like this. We’ve got the same letter A in the ones column twice. And the result has got the same digit in that column as well. The only possibility is that A is equal to zero. Now, all the digits will work in that place. But, sadly in our problem, we don’t have the same letter in the ones column. So that’s not gonna be much use to us.

What if we had the same letter in the ones column for the two numbers but then a different letter in the ones column for the answer? Then B would have to be even, 0, 2, 4, 6, or 8. But again that’s not gonna help us because that’s not the pattern we’ve got in our column. What if we had something like this? We had a letter here and in the same position in the answer and then a different letter here. Well, again, B must be equal to zero in order for this to be true. But again, that’s not gonna help us with our particular problem. Okay, what about this then? We’ve got the same letter in a column which isn’t the ones column. Well, we’ve got two possibilities. These two digits here might add up to something like 10 or 11 or 12 which creates a carry digit, a plus one, carried into that column. Or maybe they sum to a number less than 10, so there wouldn’t be a carry.

Now if a one is carried into the column, then if A was equal to nine, we’d have nine plus nine is 18 plus the one carried in would be 19. We would have a nine in that digit place there. If there wasn’t a carry in, then A equals zero would work. Interesting, but again, it’s not gonna help us with our particular problem here. What about this situation where one of the digits in our sum also appears in the answer but not in the ones column? Now again, the ones column could sum to 10 or more and have a carry or maybe it doesn’t and doesn’t have a carry. Well, if we didn’t have any carry over, then A must be zero in order for something plus B to be equal to B. But if we did have a carry coming in, then A would have to be equal to nine. So there are two possibilities. But you guessed it again. It’s not actually gonna help us with our particular problem.

Then we can consider slightly more complicated situations where our conclusions aren’t quite so clear cut. So for example, this one here. We know that the C can only be one, because when you add two numbers together the maximum carry you can get is one. And we also know that A plus B must be at least 10. So A plus B is greater than nine in order to generate that carry. But if we had carry from the ones column into this column, then A plus B could be equal to nine, because nine plus one equals 10 and that generates our carry into the hundreds column. Okay, and that’s not gonna help us with our particular problem. But it’s this sort of analysis, this style of analysis, that helps us to cross off certain possibilities from our grid.

Now before we go back to SEND plus MORE equals MONEY, let’s do MOO plus MOO equals COW to pick up some more logic tips. We know we’re not allowed leading zeros so M and C can’t be zero. Then O plus O is equal to W. Or if that result is bigger than 10, then O plus O is equal to 10 plus W. Because with O plus O, we’re adding the same number to itself, we’re doubling that number, we know that W is even. And if we look at the next column, we see that O plus O is equal to O in this column. And that tells us that there must have been some carrying from the ones column in order for the result to be different. So now we know that O must be at least five to generate that carry and there must be carry over into the hundreds column.

So O plus O in the ones column generates the W, which we said was even. When we carry one over and do O plus O plus one, O the result must be odd. And we also know that O plus O plus one gives a result ending in the digit O. So what could it be? Zero plus zero plus one is not equal to zero. One plus one plus one is not equal to one. Two plus two plus one is not equal to two. But nine plus nine plus one is equal to 19. So O must be nine. And we can replace all the Os with nines. Well, now that we know that O is nine, we know that M can’t be nine, W can’t be nine, and C can’t be nine. So if we’d make a grid, we’d be able to cross those off. But in fact, more importantly than that, here we know that W must be — nine plus nine is 18 — W must be eight. And again we know that C and M can’t be eight.

Now because we’ve got this carry here, we know that M plus M plus one is equal to C. And that tells us that this isn’t a proper cryptarithm because it’s not a unique answer. There are multiple possibilities left for M and C. We know that there’s no carry into the thousands column. So M plus M plus one is less than 10. So M plus M, that’s two M, is less than nine. And M is less than four and a half. Well, we knew that M couldn’t be zero, eight, or nine. But we’ve now just ruled out seven, six, and five as well. So the possibilities are one, two, three, or four. But if M was four, then C here would be nine. But C can’t be nine because we know that we’ve already got another letter that was nine, O. So M can’t be four either. There are three possibilities, one, two, and three. Then if M is one, one plus one plus one is equal to three. If M is two, two plus two plus one is equal to five. And if M is three, three plus three plus one is seven.

So as we said, there are three different possible combinations of values that M, O, C, and W could have. Now back to our main event, SEND plus MORE equals MONEY. Well, the answer has got an extra digit. And the maximum that could be carried over when adding two numbers is one. So we know M is equal to one and none of the other letters are equal to one. So we can cross those off, but we also know that M is not equal to any of the other digits. So we can cross those off too. And we can start mapping out those answers in a little grid. We’ve got a one here and here. Now, we know that S plus M gives us a two-digit number in order for there to be a carry over here.

And we already know that M equal to one. So S must be eight if there is a carry from here to here or nine if there wasn’t. Now in that case, O down here could be either zero or one. But we already know that M is one. So O must be zero. So we can update our working solution and our table. Now, since O is equal to zero, then the only way that we can get E plus O to be greater than nine, to generate the carry that we need down here, is for E to be nine and for there to have been a carry from the previous column. But then the answer digit would be zero and the letter at the bottom would be O not N. So we can’t have any carry over into the thousands column. And that means that S must be nine in order to generate our carry into the ten thousands column. Again, we can update our table and our working solution with S equals nine.

Now remember, in the hundreds column we said that the E plus O equals N without carry and O equals zero. So we must have had carry from the tens column. And N must be one greater than E or it would be E plus zero equals E. So we could write N plus E equals one. Now remember, in the hundreds column, we’ve said that E plus O is equal to N without carry and O is equal to zero. So we must have had carry from the tens column. Now N must be one greater than E or it’d be E plus O equals E. Now we could write N is equal to E plus one. Now looking at our grid, if N is one bigger than E, then N clearly can’t be two and E can’t be eight. Now because we need to have carry from the tens into the hundreds column, we know that N plus R, possibly plus one if there’s carry from the ones column, must be greater than nine.

In fact, we can be a little bit more specific than that. Because we know that the ones digit in the answer to N plus R possibly plus one is E, we can write N plus R possibly plus one is equal to 10 plus E. Now we’ve got two simultaneous equations that we can solve. Subtracting the first from the second gives us R possibly plus one is equal to nine. But remember, S is equal to nine, so R can’t equal nine. That means we did have to do this adding one to R to get nine. And that means that R must be equal to eight. And we can fill that out on our grid and working solution. But also remember this, N is equal to E plus one. And we know that N can’t be eight now. So we also know that E can’t be seven. So we can cross that off the grid.

Now looking in the ones column, we can see that Y has got to be at least two. So D plus E must be greater than or equal to 12. Remember, we determined that we did have to add this one here so there must be carry from the ones to the 10s column. Now looking at the remaining possible values for E and D, they’ve got to be either six and seven, either way round, or five and seven in order to add up to at least 12. But remember, we said that N is one bigger than E. So if E was six and D was seven, then N would have be seven as well. And that’s not allowed. So E can’t be six and it must be five. And that means the N must be six, which leaves us with seven for D. And that means we can easily see that Y must now be two, because seven and five is 12. What we need to do then is a final check of our adding up. Seven and five is 12. Six and eight is 14, plus one is 15. Five and zero is five, plus one is six. Nine and one is 10. And one and nothing is one.

So yep! That looks like it’s right. And there we can write out our answer. Now sometimes you get to a stage where you’ve done a lot of logical deduction and you just have to use a bit of trial and error with the last few numbers. And this is where the grid comes in handy. You can see which letter has the fewest possible digits remaining and try one of them to see where it leads. If you end up with a contradiction or an impossible situation, then that letter obviously wasn’t that value. So you can cross it off and try another one. So now you know how to solve possibly the most famous cryptarithmetic puzzle of all time. Hopefully, you can solve some more of your own.