Introduction
Cryptarithmetic (also called verbal arithmetic or alphametics) is a class of constraint puzzles where letters stand for distinct digits and a word equation holds numerically. The classic example is SEND + MORE = MONEY, whose unique solution is 9567 + 1085 = 10652. Cryptarithmetic puzzles date back to the 19th century and were popularized by Henry Dudeney and Sam Loyd. They appear in mathematics competitions, puzzle books, and cryptography curricula as an exercise in constraint satisfaction. This solver finds digit assignments that satisfy your equation using constraint-guided backtracking that runs entirely in your browser.
What this tool does
- Solves cryptarithmetic equations like SEND + MORE = MONEY in milliseconds.
- Supports any number of addends on the left side of the equation.
- Enforces the rule that leading letters cannot be zero.
- Enforces that each letter maps to a unique digit (0-9).
- Reports the solution as a digit-substituted equation plus a per-letter assignment table.
How this tool works
Type a word equation into the input field using the format WORD + WORD = WORD. The solver parses the equation, collects the distinct letters, and assigns digits one letter at a time using backtracking. At each step it prunes branches where a leading letter would be zero or a digit would be reused. When all letters are assigned, it checks whether the numeric equation holds. If a solution is found, the tool displays the digit-substituted equation and a table mapping each letter to its digit. If no solution exists (for example, the equation uses more than 10 distinct letters), the tool reports that no solution was found. The solver stops after finding the first solution.
How cryptarithmetic solving works
Cryptarithmetic is a constraint satisfaction problem. Each letter is a variable with domain 0-9. The constraints are: all variables must take distinct values, leading letters cannot be zero, and the arithmetic equation must hold when letters are replaced by their digits. The solver uses backtracking with forward checking. It processes letters in order of first appearance, trying digits 0 through 9 for each. The leading-letter constraint prunes the zero branch for word-initial letters. The distinct-digit constraint prunes any digit already in use. When all letters are assigned, the solver evaluates the equation. For SEND + MORE = MONEY, there are 10 letters (S, E, N, D, M, O, R, Y, and the implicit constraint that M must be at least 1), and the search space is small enough that the solution is found almost instantly. Larger puzzles with more letters may take longer but are still tractable up to the 10-letter limit imposed by the decimal digit set. Cryptarithmetic puzzles are NP-complete in general, but practical instances are small enough for backtracking.
How to use this tool
- Type a word equation in the format WORD + WORD = WORD (e.g. SEND + MORE = MONEY).
- The solver parses the equation and identifies the distinct letters.
- It assigns digits via backtracking, pruning invalid branches immediately.
- If a solution exists, the digit-substituted equation and letter table appear in the output field.
- If no solution exists, the tool reports that the equation is unsolvable.
Real-world examples
The classic: SEND + MORE = MONEY
Input: `SEND + MORE = MONEY`. Output: `SEND=9567 + MORE=1085 = MONEY=10652`. Letter assignments: D=7, E=5, M=1, N=6, O=0, R=8, S=9, Y=2.
CROSS + ROADS = DANGER
Input: `CROSS + ROADS = DANGER`. The solver finds the digit assignment that makes the equation hold, if one exists.
DONALD + GERALD = ROBERT
Input: `DONALD + GERALD = ROBERT`. This classic puzzle has a unique solution that the solver finds by backtracking through the 10 distinct letters.
Comparison with similar methods
| Method | Complexity | Typical use |
|---|---|---|
| Backtracking solver | O(10^k) worst case, k = letters | Cryptarithmetic puzzles up to 10 letters |
| Brute force | O(10^k) — all assignments | Impractical for k > 8 |
| Constraint propagation | Better average case | Larger constraint problems |
| SAT solver | NP-complete | Industrial constraint solving |
Limitations or considerations
The solver handles equations with at most 10 distinct letters, since there are only 10 decimal digits. It finds the first solution and stops; some puzzles have multiple solutions, but only one is reported. The equation format requires the plus sign and equals sign; other operators (minus, multiplication) are not supported. Very large puzzles at the 10-letter limit may take several seconds. The solver does not verify uniqueness of the solution.
Frequently asked questions
What is the most famous cryptarithmetic puzzle?
SEND + MORE = MONEY, whose unique solution is 9567 + 1085 = 10652. It is attributed to Henry Dudeney and appears in most introductory cryptography and puzzle texts.
Why can leading letters not be zero?
Because numbers do not have leading zeros in standard notation. A word like SEND represents a four-digit number, so S cannot be 0. The solver enforces this constraint during backtracking.
Can the solver handle multiplication or subtraction?
This version supports addition only (WORD + WORD + ... = WORD). Multiplication and subtraction puzzles require a different parser and are not supported.
How many distinct letters can the solver handle?
Up to 10, because there are only 10 decimal digits (0-9) and each letter must map to a distinct digit. Equations with more than 10 distinct letters have no solution.
Conclusion
The Cryptarithmetic Solver finds digit assignments for word equations like SEND + MORE = MONEY using constraint-guided backtracking. It enforces the standard rules (distinct digits, no leading zeros) and reports the solution as a digit-substituted equation with a per-letter assignment table. The solver is a useful tool for puzzle enthusiasts, mathematics students, and anyone studying constraint satisfaction.