# General Approach to Solving Cryptarithms

I have recently started honing my problem-solving skills, starting with number-related puzzles. Cryptarithms have appeared frequently, so I was wondering whether there is some sort of general approach to solving these problems? Such as a sequence of reproducible steps? The cryptarithms I want to solve mainly involve addition.

I understand that for easier examples, such as "AB + AB + AB = CB" , common sense can be used to recognise simple facts (in this case, B must be 0 or 5). However, for harder examples that involve multiple solutions or higher-digit numbers, I find myself struggling without making any progress.

Guidance on how to approach these problems would be much appreciated.

• My suggestion: click on the alphametic tag and have a look at some of the previously asked alphametic questions. Read the solutions with your question in mind: is there a general approach? What are some strategies that appear frequently? Commented Jul 27, 2021 at 14:26
• @bobble Mainly addition... Commented Jul 27, 2021 at 14:33
• My suggestion: use a computer Commented Jul 13 at 2:51
• You are assume base 10 to get the above. There are other bases that give same result and yet others that result different values. For binary B=0,1. For base 3 it will be only 0. To the best of my experience each problem requires unique approach.
– Moti
Commented Jul 13 at 5:22

Unless you count things like "use a computer to just try all the possibilities", I don't think there's any really systematic approach. But here are some things I do when solving cryptarithms.

• Be very familiar with how written-out arithmetic works, and with arithmetic modulo 10.
• E.g., if you know that 2xX=Y aside from possible carries out then you know Y=0,2,4,6,8 and you know that possible values of X come in pairs 5 apart; if you know that 3xX=Y apart from possible carries out then you know that there's one possible X for each digit Y and if you see Y=7 you know immediately that X=9, etc.
• Look for repeated letters.
• If one column of an addition says X + Y = X, that means (not quite that Y=0 but) that Y, plus any carry from the right, equals 0 or 10.
• If one column of an addition says X + X = Y, that means (not quite that 2X=Y but) that twice X, plus any carry from the right, equals Y or Y+10.
• Look for repeated combinations of letters.
• Suppose you have one column of an addition saying X+Y=A and another saying X+Y=B. That means (not quite that A=B but) that A and B are at most 1 apart mod 10 -- they could e.g. be 0 and 9 -- and any difference is the result of different carries coming in from the right. (If letters A and B are different then you know that they are exactly one apart, hence that one column has a carry-in and the other doesn't.)
• Suppose you have two columns of an addition that both look like ...+X+... = Y. That means (not quite that the two instances of ...+... are equal but) that the two instances of ...+... are at most 1 apart mod 10, and any difference is the result of different carries.
• Look for places where reasoning about carries is particularly effective.
• If you add two numbers and get a longer number, then (1) the extra digit on the left must be a 1 and (2) the leftmost addition must produce a carry.
• Do your working in a text-editor on a computer, so that e.g. it's easy to replace every Q with a 5 once you work out that Q=5, or to take two copies of your working and explore the hypotheses T=1 and T=6, or whatever. This may also make it more convenient to:
• Write down everything you know; don't rely on your memory.
• Don't be afraid to try several possibilities and see what happens. E.g., if you've got something like PxQR=RQQ and you know P+R=11 then you can look at each possible value of P, each one will give you an equation like 8xQ3=3QQ, and then for each of those you can just look at the rightmost digit to see what Q has to be and check it. This doesn't take much work and will (as it turns out) determine the values of all three digits. If you have something like an unknown carry-in then it's a bit more work and will tell you a bit less, but it might still be worth it.
• Develop a sense of what's "enough information to make progress". Roughly speaking, if you have some set of n unknown letters then there are about 10^n possibilities for them, and each relationship between them (e.g., from a column of an addition) takes away 9/10 of the possibilities, so if you have at least as many relationships as unknowns then you should expect "only a few" solutions, if you have one more unknown than known-relationship you should expect "on the order of 10" solutions, etc. This is all very crude and you should e.g. be aware that once you've already determined some letters, the usual "all letters are different" constraint will reduce the number of possibilities.
• When you have a few letters whose values are related in known ways, it can be useful to draw up a table showing all the possibilities for them. Especially because sometimes you know things like "X cannot be 3" (e.g. because that would put a 0 at the start of a number somewhere or require two different letters both to be 7) and drawing up the table will make it more likely that you notice that taking P=6 eventually requires X=3. Speaking of which:
• Don't forget about the less-powerful constraints: all digits different, no 0 at the left-hand end of a number. (Assuming that those conditions apply in your puzzle, which they usually do.)
• Be on the lookout for inequality constraints ("A<B" etc.), which you can get from the left-hand ends of additions or subtractions or anywhere else where you can tell whether or not a leftward carry happened. (You get more of these in puzzles that involve multiplication or division.)

None of the above is anywhere near to being a consistent repeatable process; the best I can do with that is "repeatedly make all the easy inferences you can, and if you're sure you have no more of those then try all the possibilities for some letter that you know some things about and see what they give you". And, at a higher level of abstraction, solve a bunch of these and look at other people's solutions here on PSE, and you'll likely get better at it as you go. You can and should combine these. Find a tricky puzzle on PSE. Attack it yourself. If you get stuck: find the accepted answer and start reading its solution, bit by bit; as soon as you see something you hadn't figured out yourself, stop reading, make sure you understand the reasoning, ask yourself "why didn't I see that, and how could I have thought of it?", and then continue trying to solve the puzzle with the new thing you've learned. If you get stuck again, return to the solution. Etc.

As Gareth's post is close to unbeatable and I think it would be nice to have one authoritative comprehensive answer, this cw is for donations which Gareth may or may not choose to incorporate in his answer.

Sometimes, digit sums can provide constraints. For example, given a sum abc+de=fgh we can infer a+b+c+d+e-f-g-h is nonnegative and a multiple of 9.