『パズルで鍛えるアルゴリズム力』の第2章で紹介されている「覆面算」をPythonで取り組んでみました。
2_2_fukumen_solver.py
実行
% python 2_2_fukumen_solver.py 3 SEND MORE MONEY The num of solutions: 1 9 5 6 7 1 0 8 5 1 0 6 5 2 % python 2_2_fukumen_solver.py 5 THERE ARE APPLE AND BANANA The num of solutions: 1 9 6 8 3 8 4 3 8 4 7 7 2 8 4 5 0 1 4 5 4 5 4