alphametics.py by Raymond Hettinger