TAOCP 7.2.1.2 Exercise 49
Consider an additive alphametic in base $10$ of the form \text{SEND} + \text{MORE} = \text{MONEY}, where distinct letters represent distinct digits in ${0,1,\dots,9}$ and leading letters $S$ and $M$ a...
Section 7.2.1.2: Generating All Permutations
Exercise 49. ▶ [28] [28] The text’s suggested method for solving additive alphametics with Algo- rithm X essentially chooses digits from right to left; in other words, it assigns tentative values to the least significant digits before considering digits that correspond to higher powers of 10. Explore an alternative approach that chooses digits from left to right. For example, such a method will deduce immediately that M = 1 when SEND + MORE = MONEY. Hint: See exercise 25.
Verified: yes
Solve time: 1m53s
Setup
Consider an additive alphametic in base $10$ of the form
$$ \text{SEND} + \text{MORE} = \text{MONEY}, $$
where distinct letters represent distinct digits in ${0,1,\dots,9}$ and leading letters $S$ and $M$ are nonzero.
Write the column-wise addition with carries $c_0,c_1,c_2,c_3,c_4$ from right to left, where $c_0=0$ and
$$ \begin{aligned} D + E &= Y + 10c_1,\ N + R + c_1 &= E + 10c_2,\ E + O + c_2 &= N + 10c_3,\ S + M + c_3 &= O + 10c_4. \end{aligned} $$
The most significant digit of the result is $c_4$, so $M=c_4$.
The task is to describe a left-to-right constraint propagation method and show how it forces immediate deductions such as $M=1$.
Solution
A left-to-right strategy reverses the usual propagation order by treating the most significant column as the initial constraint source. Instead of beginning with the units column and propagating carries upward, the method begins with the thousands column and treats all unknowns as constrained by the requirement that the final sum must produce a valid leading digit.
The thousands column equation is
$$ S + M + c_3 = O + 10c_4, $$
and the next column to the left contributes the fact that the result has exactly five digits. This forces $c_4 \neq 0$, since otherwise the sum of two four-digit numbers would produce at most a four-digit number. Hence $c_4=1$.
Since $M=c_4$ by definition of the leading digit of $\text{MONEY}$, it follows that $M=1$.
This deduction occurs before any assignment to lower columns, since it depends only on the structure of the addition and the number of digits involved. The constraint propagates downward in the sense that fixing $c_4=1$ restricts the allowable triples $(S,M,c_3)$ in the thousands column to those satisfying
$$ S + 1 + c_3 = O + 10. $$
Thus $S + c_3 \ge 9$, which forces $S \in {8,9}$ because $c_3 \in {0,1}$.
The general left-to-right procedure mirrors Algorithm X by treating each column equation as a constraint node whose admissible digit triples form rows in an exact cover instance. In this orientation, columns corresponding to high powers of $10$ are selected first. Each assignment reduces the admissible set of remaining rows by eliminating digit combinations inconsistent with already fixed carries and leading digits. When a variable appears in only one remaining admissible configuration, it becomes forced, and the assignment is committed before descending to less significant columns.
This differs from the right-to-left strategy in that carries are determined from partial global feasibility rather than accumulated from local digit sums. The propagation direction replaces incremental carry construction with global digit-range constraints, especially those induced by positional length.
In the present example, the positional constraint alone fixes $M$ without reference to any lower column.
Verification
The sum of two four-digit numbers lies in ${0,\dots,19998}$. The only way to obtain a five-digit result is for the leading digit of the sum to be $1$, so $c_4=1$. Since $M$ is the leading digit of $\text{MONEY}$, the identification $M=c_4$ forces $M=1$.
No other digit assignment can produce a five-digit result beginning with a digit different from $1$, since the maximum possible carry from the thousands column is $1$. Hence the deduction does not depend on any lower-column constraints and is logically complete at the first step.
This completes the proof. ∎