This project implements a genetic algorithm to solve a Cryptarithmetic puzzle where each letter represents a digit, and the goal is to find a digit assignment that satisfies the equation. The genetic algorithm uses a population-based approach to evolve potential solutions over generations.
- Python 3.x
- NumPy library
-
Clone the repository:
git clone https://github.com/phdangg/cryptarithmetic_genetic_search.git
-
Navigate to the project directory:
cd cryptarithmetic_genetic_search
-
Run the solver for different levels:
python main.py
The solver will process input files in the
level_1
,level_2
, andlevel_3
folders and output the results.
The input equations should be provided in a specific format:
- Use uppercase letters (A-Z) for variables.
- Operators allowed: +, -, *, =.
- Parentheses are allowed for nested expressions.
Example:
SEND + MORE = MONEY
The program will output the solution to each equation or indicate if there is no solution. The results will be stored in output files with the prefix "output" in the same directory as the input files.
Check the level_1
, level_2
, and level_3
folders for example input files and corresponding output files.