Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Efficient way of Solving Cryptarithms

Hi i came across this puzzle which is a subset of famous kind of word and numbers based puzzles called Cryptarithms. Say you have an expression as

S E N D + M O R E = M O N E Y

Now the interesting part there is that, each alphabet is representing a unique digit from 0-9. I wanted to write a generalized solver, but i ended up writing a brute forced solution for it. Any takers as how can i solve it?

I think it can be solved using predicate logic or set theory. And i'm particularly interested in finding C# or Python based solutions. Any one.?

like image 211
Anirudh Goel Avatar asked Apr 15 '09 09:04

Anirudh Goel


People also ask

How do you solve sending money?

So we have solved for all the letters! SEND + MORE = 9567 + 1085 = 10652.

Can Cryptarithmetic problems have multiple solutions?

Ideally, a good cryptarithmetic puzzle must have only one solution[2]. We derogate from this tradition. The above example has multiple solutions.


1 Answers

At PyCon 2009 Raymond Hettinger talked about AI programing in Python, and covered Cryptarithms.

The video of entire talk can be seen here, and cookbook with Python 2.6 solution can be found at this link.

like image 109
Josip Avatar answered Oct 07 '22 07:10

Josip