『パズルで鍛えるアルゴリズム力』の第1章で紹介されている「虫食算」をPythonで取り組んでみました。
1_3_mushikui_solver.py
実行
% python 1_3_mushikui_solver.py Mushikuizan Input: 2 2 *1 2* **3 *4* **** The num of solutions: 1 1 th solution: 71 * 23 = 1633 % python 1_3_mushikui_solver.py Mushikuizan Input: 3 2 *1* ** 2*** **3 ***4 The num of solutions: 1 1 th solution: 313 * 18 = 5634 % python 1_3_mushikui_solver.py Mushikuizan Input: 6 4 ****** **** 1234*** ****5** ****6* ***7890 ********** The num of solutions: 1 1 th solution: 176315 * 6487 = 1143755405