$\begin{array}{ccccc} & & & M& A &S&S\\ + & & & W& E & I &G \\ \hline & & & P & H &Y & S\\ \hline \end{array}$

In the cryptogram above, each letter represents a distinct single digit non-negative integer. What is the largest possible value of $\overline{PHYS}$ ?

The answer is 9817.

**
This section requires Javascript.
**

You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.

Looking at the units column, clearly $G = 0$ and there is no carry to the tens column. Now ignore the units column, and remember that none of the digits may be 0 (since it's used for $G$ ).

There are 9 letters and 9 digits, so all digits get used. Adding up all the digits gives $M+A+S+W+E+I+P+H+Y$ , which must be equal to $1+2+3+4+5+6+7+8+9 = 45$ . Now consider the addition modulo 9. $\overline{MAS} + \overline{WEI} + \overline{PHY} \equiv 45 \pmod 9$ , since we can obtain the remainder modulo 9 by adding up the digits. However, $\overline{MAS} + \overline{WEI} = \overline{PHY}$ , so we have $2 \cdot \overline{PHY} \equiv 45 \equiv 0 \pmod 9$ and so $\overline{PHY} \equiv 0 \pmod 9$ . In other words, $\overline{PHY}$ is divisible by 9. The largest possible number for $\overline{PHY}$ is hence 981, and the largest possible $S$ after this is 7, giving $\max \overline{PHYS} = \boxed{9817}$ . This is achievable, by for example $3277 + 6540 = 9817$ .