Crypt
Arithmetic
Solver

AI-powered CSP engine with backtracking search [made by Team 3 (AM2)]

Try a puzzle โ†’

Use uppercase letters. Supports + and - operators. One = sign required.

Play
Mode

Guess the digit mappings before the AI does

๐ŸŽฎ

Select a puzzle above to start playing!

How It
Works

The AI concepts behind the solver

๐Ÿ”

What is Crypt Arithmetic?

Crypt Arithmetic is a type of mathematical puzzle where digits are replaced by letters. Each letter represents a unique digit (0โ€“9), and the goal is to find an assignment that makes the arithmetic equation valid.

S E N D
+ M O R E
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
M O N E Y

The classic SEND+MORE=MONEY has a unique solution: S=9, E=5, N=6, D=7, M=1, O=0, R=8, Y=2.

๐Ÿงฉ

Constraint Satisfaction Problem (CSP)

A CSP is defined by three components:

  • Variables โ€” each unique letter in the puzzle
  • Domain โ€” digits 0โ€“9 for each variable
  • Constraints โ€” all-different digits, no leading zeros, equation must hold

The solver narrows down possibilities by propagating constraints before and during search, dramatically reducing the search space compared to brute force.

๐Ÿ”

Backtracking Algorithm

Backtracking is a depth-first search with pruning. It works like this:

  1. Pick the next unassigned letter
  2. Try each digit in its domain
  3. Check if constraints are still satisfied
  4. If yes โ†’ recurse deeper; if no โ†’ backtrack
  5. Continue until all letters are assigned (solution!) or all options exhausted (no solution)
Worst case: 10! = 3,628,800 iterations With pruning: often solved in < 1,000
โšก

Optimizations Used

  • Constraint Propagation โ€” eliminate impossible values early
  • Most Constrained Variable (MCV) โ€” assign letters in order of appearance to enable early failure detection
  • Forward Checking โ€” verify partial assignments satisfy column-wise carry constraints
  • Leading Zero Pruning โ€” immediately reject any assignment that puts 0 on a leading letter