# A mathematician's coffee alphametic

Alfréd Rényi, a Hungarian mathematician, said that a mathematician is a machine for turning coffee into theorems. It's believed that his mention was about his colleague, Paul Erdős, the celebrated mathematician.

How much coffee had he drunken for his theorems? I think that he would drink 3 cups of coffee per theorem. :-)

  COFFEE
COFFEE
+ COFFEE
--------
THEOREM

• That is an astonishingly efficient mathematician! (or trivial theorems) Jan 30, 2015 at 7:57
• This may be more obvious to some - but are we assuming that two letters can't represent the same digit? E.g. can R and M both be 7? Jan 30, 2015 at 14:52
• @frodoskywalker I agree. He was very prolific. As for ordinary mathematicians, the truth about coffee is: COFFEE + COFFEE + COFFEE + COFFEE + COFFEE + COFFEE + COFFEE + COFFEE + COFFEE + COFFEE + COFFEE + COFFEE + COFFEE + COFFEE + COFFEE + COFFEE + COFFEE + COFFEE = THEOREM. Jan 30, 2015 at 16:52
• @P.-S.Park - That is indeed another way to turn multiple COFFEEs into a THEOREM, where COFFEE=210088 and THEOREM=3781584. Per the standard rules (each letter represents a single base 10 digit, different letters represent different digits, and the first letter of each word represents a non-zero digit), the only ways to turn COFFEE into THEOREM are COFFEE+COFFEE+COFFEE=THEOREM (one solution), COFFEE+COFFEE+COFFEE+COFFEE=THEOREM (four solutions), and COFFEE+COFFEE+...+COFFEE=THEOREM (18 COFFEEs, one solution). Jan 31, 2015 at 19:06
• @DavidHammen Yes, it's another way. Of course, the unit of measure is a barrel. Feb 2, 2015 at 13:20

Letter values:

C = 8, O = 3, F = 1, E = 9, T = 2, H = 4, R = 5, M = 7.

The equation:

 831199 831199 + 831199 -------- 2493597

• How did you figure out the F or R? I couldn't get passed the M and E. Jan 29, 2015 at 15:04
• @KevinVoorn In the second column (O + O + O = E), you can see that if you had a number "carried" from the third column, the only carried number that would let you make Ox3 = E is 3. That can't be carried, as the maximum number you could make is 27 (9x3). So there can be no carried numbers there, meaning that O x 3 must be equal to E. That being the case, the only way that (F + F + F = O) could be true in the third column is if it had no carried numbers as well... If that makes sense. Jan 29, 2015 at 15:08
• It makes a lot of sense, thanks. I couldn't figure out how to get to the second E to get an answer, but now I got it as well :) Jan 29, 2015 at 15:10
• @EFrog, actually the 3xO=E can be: 1) no carry from previous column => O=3, 2) carry 1 from previous column => O=6, 3) carry 2 from previous column => O = 9. The second case implies that F=5 and R=7, but M is already 7, so it can't be. The third case cannot happen because E is already 9. Jan 30, 2015 at 13:03

Well, first, we can determine E, since $E*11*3 = 100's + 10*E + change$. Only number that fits is $E = 9, M = 7$. (Another way to think of it is to take each number times 3, add the digits and figure out which one matches; 9*3=27, 2+7=9)

Now, O and F are interesting, since the 10's of $F*11*3 = O$ and $3*O + (3*F \% 100) = 9$. If O = 3, then F<=3, since it can't rollover to the hundreds. If F = 1, then we have no rollover. So, $O = 3, F = 1, R = 5$

So, that just leaves us with $3*C = TH$ without repeating a digit. C >= 7, since it has to be 2 digits and 1 is already taken. 8 works, since 24 is good. So, $C = 8, T = 2, H = 4$

Noting that 3*E gives a different result in the first two columns, there must be an overflow i.e. E is greater than 3. This overflow can only be 1 or 2 (you cannot get more than 27 from tripling a single digit), and in the second column 3*E + overflow => E. This means 2*E + overflow (which is 1 or 2) equals either 10 or 20. E=9 is the only number which satisfies this, so E=9, M=7:

  COFF99
COFF99
+ COFF99
--------
TH9OR97


seeing that 3*O + (overflow from 3*F) = 9, O=3 and the overflow is zero (the overflow could only have been 0, 1 or 2, and only 0 is compatible with the result being divisible by 3).

  C3FF99
C3FF99
+ C3FF99
--------
TH93R97


but 3*F + (overflow from 3*F, which we know is 0) = 3, so F=1

  C31199
C31199
+ C31199
--------
TH93597


which also gives R=5. Now 3*C = TH. T can only be 1 or 2, and 1 is taken. T=2. To give an overflow of 2, C must be greater than 6. But 7 and 9 are already taken, so C=8, forcing H=4

  831199
831199
+ 831199
--------
2493597

• the overflow could only have been 0, 1 or 2, and only 0 is compatible with the result being divisible by 3. No, all overflows are compatible with the result being divisible by 3. That's because 3xO can also overflow. 3x3 = 9, 3x6+1=19 and 3x9+2=29 all fit the 3xO+(overflow from 3xf)=9 (= here being congruency). The actual reason O=3 is this. Jan 30, 2015 at 13:07
• @Shahbaz You're right, not sure how I missed that. I will revise it. Jan 30, 2015 at 13:27

Assuming that a letter can have the same value as another letter, these are some lazy solutions.

T = 1, H = 2, C = 4, E = F = M = O = R = 0
T = 1, H = 5, C = 5, E = F = M = O = R = 0
T = 1, H = 8, C = 6, E = F = M = O = R = 0
T = 2, H = 1, C = 7, E = F = M = O = R = 0
T = 2, H = 4, C = 8, E = F = M = O = R = 0
T = 2, H = 7, C = 9, E = F = M = O = R = 0

• If you allow duplicate values, there are 40 solutions. Jan 30, 2015 at 11:07

Since the 'normal' solutions have all been found, have the brute force method:

Python2:

for c in xrange(333333,1000000):
t=3*c
theorem=str(t)
coffee=str(c)
if theorem!=theorem:continue
if theorem!=coffee:continue
if coffee!=coffee:continue
if coffee!=coffee:continue
if coffee!=theorem:continue
if len(set(coffee))!=4:continue
if len(set(theorem))!=6:continue
if len(set(coffee+theorem))!=8:continue
print coffee,theorem