Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/singiamtel/cryptarithmetics
Small algorithm to solve any word addition problem via backtracking
https://github.com/singiamtel/cryptarithmetics
Last synced: 24 days ago
JSON representation
Small algorithm to solve any word addition problem via backtracking
- Host: GitHub
- URL: https://github.com/singiamtel/cryptarithmetics
- Owner: singiamtel
- License: gpl-3.0
- Created: 2021-05-03T01:35:41.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-02-02T12:06:23.000Z (9 months ago)
- Last Synced: 2024-02-02T13:55:25.770Z (9 months ago)
- Language: C++
- Size: 20.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Cryptarithmetics
> Verbal arithmetic, also known as alphametics, cryptarithmetic, cryptarithm or word addition, is a type of mathematical game consisting of a mathematical equation among unknown numbers, whose digits are represented by letters of the alphabet.
_Via [Wikipedia](https://en.wikipedia.org/wiki/Verbal_arithmetic)_
This small program intends to demonstrate how you could solve any alphametics problem using backtracking. (This is not the most efficient way to solve them, [Diophantine equations](https://en.wikipedia.org/wiki/Diophantine_equation) would outperform this method)
# Example problem
```
CP
IS
+ FUN
--------------------------
TRUE
```One solution to this problem would be:
```
23
78
+ 945
--------------------------
1046
```The program will solve for every possible solution
# Problem constraints
A solution will be considered valid when:
- Every letter has a value in the interval [0,9]
- No two letters share the same value
- The equation is trueNo input can be over 10 unknowns, as we're solving only for [0,9]
# Try it out
You can compile the binary executing `make`, then running `./crypt`
If you don't have a C++ environment, or would just rather try it online, you can do it [here](https://onlinegdb.com/BynUnR3wd)