這是一種簡單的基於隊列的方法,可以以最少的步驟求解數字拼圖。
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!