这是一种简单的基于队列的方法,可以以最少的步骤求解数字拼图。
python solver.py 1 2 3 4 10 25 --target 81
(其中六个数字是虚线圆中概述的六个数字,而81是您要达到的大数字) $ python3 solver.py 5 11 19 20 23 25 -t 413
Found a solution in 4 steps. Run with --spoil to see the details.
$ python3 solver.py 5 11 19 20 23 25 -t 413 --spoil
Found a solution in 4 steps:
20 ➖ 11 ? 9
23 ➕ 25 ? 48
9 ✖️ 48 ? 432
432 ➖ 19 ? 413
我在test_solver.py
中有一些最小测试。运行python -m unittest
以查看您进行更改后是否有效。
在mastodon上找到我:https://takahe.social/@drew
欢迎PR!