# Neil Armstrong and Buzz Aldrin alphametic

Every letter stands for a digit in decimal representation, different letters stand for different digits:

      MEN + CAN = REACH - MOON


Which digit does each letter represent?
(Please present the full analysis how these digits can be determined.)

• Can we assume that M, C, R don't represent 0? Feb 9, 2016 at 13:37
• Yes: MEN and CAN are three-digit numbers, MOON is a four-digit number, REACH is a five-digit number. Feb 9, 2016 at 13:48
• There is definitely an answer, which I have verified using a script. I won't post it given the no-computers tag, but there is certainly an answer. Feb 9, 2016 at 16:35

902 + 382 = 10836 - 9552

Solution.

First there are the "gimme" digits.

We can rewrite this as MEN + CAN + MOON = REACH. A crude upper bound for the right hand side is 9999 + 999 + 999 which is 11997 yielding R = 1. Then we know that E is also either 0 or 1; digit-distinctness forces E = 0. We use this to pin down M as either 8 or 9; 7 is too small as 7999 + 709 + 999 does not clear 10,000. So those are the easy constraints here.

After that you can condense two pairs of digits together and simplify the problem considerably:

Writing out what we know, m0n + can + moon = 10ach. Reading this modulo ten, we see 3n = h (mod 10). Since 3 and 10 are coprime, the map x -> 3x is a permutation of the digits 0..9 modulo 10. So there is only one degree of freedom here, and we can write m00 + ca0 + moo0 = 10ac0 + w where w = (3*n-h)/10. More explicitly here is a table:

     n        =   0    1    2    3    4    5    6    7    8    9
h        =   0    3    6    9    2    5    8    1    4    7
allowed? =   X    X        m=8        X   m=9   X   m=9  m=8
(3*n - h)/10 =             0    0    1         1         2    2
We can see that w is bounded between 0 and 2, and lets us look up a couple pairs of (h, n) numbers. This will be crucial for quickly brute-forcing the rest. When we divide the whole equation by 10 we now have:
    m0 + moo = 1000 + (ac - ca) - w
Now comes our second pair that we can condense: we rewrite ac - ca as 9 * (a - c). Defining x = a - c we can see that x is bounded between 9-2 = +7 and 2-9 = -7, so it can be negative, which is important. We will be using it to take certain guesses for o and try to bring them within 0,1,2 for a value of w. Our current equation is just:
    11*o  - 9 * x + w = 1000 - 110 * m.
Now we are ready to investigate particulars.

For m=8 we see that 11 * o - 9 * x + w = 120. Clearly o > 1 from our distinct-digit constraint, and since w is so small we will need negative x to fight to bring this 120 down to the appropriate range. Here is a table of the possibilities:
     o          =     2    3    4   5   6   7   8   9
120 - 11*o =    98   87   76  65  54  43  32  21
-9*x       =    90   81   72  63  54  36  27  18
w        =     8    6    4   2   0   7   5   3
So we see that when m=8 we have only two possibilities: o=5 and o=6.

When m=8, o=5 we have c = a + 7 and w = 2. The above table for w shows that w=2 only when (n=9, h=7). This leaves no possibilities for c, as a is minimum 2 and thus c is minimum 9. Dead end.

When m=8, o=6 we have c = a + 6 and w = 0, which permits (n=2, h=6), forbidden as o=h, or (n=3, h=9), forbidden because again a is minimum 2 and thus c is minimum 8, but both 8 and 9 are occupied. Also a dead end.

So we conclude m = 9. Our equation is now 11*o - 9*x + w = 10. The restriction on w is still as onerous as ever:

o          =     2    3    4    5    6    7    8
10 - 11*o  =   -12  -23  -34  -45  -56  -67  -78
-9*x       =   -18  -27  -36  -45  -63  -72  -81
w          =     6    4    2    0    7    5    3
(When o=9 it conflicts with m; also you get a = c + 9 which is similarly impossible.) So we have only two possibilities here:
When (o=4, w=2) we have (n=8, h=4), but again o = h, BZZT NO.

When (o=5, w=0) we have (n=2, h=6), a = c + 5. This is only possible with c = 3, a = 8, because n has 2 and m has 9. DING DING DING.

This is the above solution and it is unique.

• Could you possibly make this more readable? Put two spaces on the end of a line to enforce a new line. Feb 9, 2016 at 16:34
• @jhabbott with that and some other advice about how to make code blocks in spoiler tags I think I've got it sorted out. Feb 9, 2016 at 16:48

R=1 E=0 M=9 O=5 A=8 C=3 N=2 H=6

which yields:

902 + 382 = 10836 - 9552

Solution:

Since MOON<9999, MAN<999, CAN<999, REACH <12000, hence R=1. Also from the above, E<2, but E=1 is impossible because R=1 already, hence E=0.

Then

If M<=7, since MAN<999, CAN<999, MOON<7999, MAN+CAN+MOON < 10,000. Hence M>7. We assume M=9.

Then

We can simplify the equation given by writing, insteand of CAN, for instance, CAN -> 100C + 10A +N, which allows the following simplification:

Here

3N-H = 10 (10 +9(A-C)-11 O)

Hence

Since the rightmost term, 10 +9 (A-C)- 11 O, is an integer, also (3N-H)/10 must be an integer. It is easy that we can only have X=(3N-H)/10=0,1,2.

Rewriting the above,

10 = 11 O - 9(A-C) +X

which can be easily solved by trial and error. It turns out that

the only solution is O=5, A-C=5, X=0. In order to have X=3N-H=0, we can only have N=2,H=6 because the other possible solution, N=3,H=9 is prohibited by the fact that 9 is already allocated to M.

On the other hand,

A-C=5 has the unique solution A=8,C=3, given that the other possible solutions, 0,5 - 1,6 - 2-7, 4-9, would all use digits which are allocated.

A similar treatment

shows that, for M=8, there are no other possible solutions.