✨ Discover the logic behind the letters

Solve Cryptarithms
In Milliseconds.

Unravel word-math puzzles instantly. Our advanced backtracking algorithm cracks complex equations like SEND + MORE = MONEY effortlessly.

Lightning Fast

Optimized DFS pruning evaluates thousands of states per second.

🧠

Smart Algorithm

Learn the backtracking strategy that powers the engine.

🎨

Beautiful UI

Sleek glassmorphism design with dark & light modes.

Puzzle Solver

Learn Cryptarithmetic

Understand the math, rules, and algorithms behind the puzzles.

Cryptarithmetic (also called alphametics) is a type of mathematical puzzle where digits are replaced by letters. The goal is to find a digit for each letter so the resulting arithmetic equation is correct.

SEND + MORE = MONEY

Each letter stands for a unique digit (0-9), and the equation must hold true when letters are replaced by their assigned digits.

  • Each letter represents a unique digit (0–9).
  • No two different letters can map to the same digit.
  • The leading letter of any multi-letter word cannot be zero (no leading zeros).
  • Standard base-10 arithmetic applies, including carrying.
  • Usually a puzzle has exactly one valid solution.

Addition

SEND + MORE = MONEY

Multiplication

IS × SO = TOO

Multi-addend

EARTH + AIR + FIRE + WATER = NATURE

Let's walk through the classic puzzle.

  1. Identify unique letters: S, E, N, D, M, O, R, Y — 8 letters.
  2. Leading letters: S and M cannot be 0.
  3. Column analysis (rightmost first):
    • D + E = Y (+ possible carry)
    • N + R (+ carry) = E (+ carry × 10)
    • E + O (+ carry) = N (+ carry × 10)
    • S + M (+ carry) = MO (two digits → M must be 1)
  4. Deduction: Since MONEY is 5 digits and SEND/MORE are 4, M = 1 and S ≥ 8. With constraints, S = 9.
  5. Continue back-substituting to get O = 0, E = 5, N = 6, D = 7, R = 8, Y = 2.
9567 + 1085 = 10652 ✓

Backtracking is a Depth-First Search (DFS) strategy that builds candidates incrementally and abandons a branch as soon as it detects the partial solution is invalid.

function solve(charIndex) {
  if (charIndex === chars.length) {
    return evaluate();      // check if sum == 0
  }
  for (digit = 0 to 9) {
    if (digit not used AND passes constraints) {
      assign(chars[charIndex], digit);
      if (solve(charIndex + 1)) return true;
      unassign(chars[charIndex]);
    }
  }
  return false;             // backtrack
}

Pruning optimizations:

  • Leading-zero skip — skip digit 0 for first letters.
  • Weight-based evaluation — convert words to character weights (base-10 positions), check weighted sum equals zero instead of evaluating full words each time.
  • Constraint Satisfaction Problems (CSP) — Foundation for AI planning and scheduling.
  • Cryptography — Understanding substitution cipher techniques.
  • Education — Teaching logical/mathematical reasoning in schools.
  • Competitive Programming — Common puzzle type in coding contests.
  • Game Design — Puzzle games based on alphametic concepts.

About the Project

A client-side demonstration of backtracking algorithms applied to Cryptarithmetic puzzles.

🛠️ Technologies Used

HTML5 CSS3 JavaScript Backtracking DFS Pruning Glassmorphism Responsive Design LocalStorage

⚙️ How it Works

The solver converts each word into base-10 positional weights per character. It then uses recursive DFS with backtracking, assigning digits 0-9 to unique letters and checking if the weighted sum equals zero. Leading-zero constraints are enforced as pruning steps.

📂 Project Structure

  • index.html — Structure & content
  • style.css — Styling, animations, themes
  • script.js — Solver logic, UI interactions

🎓 Purpose

Built as a college project to demonstrate the application of Artificial Intelligence and Constraint Satisfaction concepts in a modern, interactive web interface.