Search code examples
c#pythonsolvercryptarithmetic-puzzle

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.?


Solution

  • 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.