🧩 Sudoku Generator & Solver

Generate Sudoku puzzles at several difficulties complete with reference solutions, or paste an existing puzzle to solve it — for practice and leisure.

📐 工作原理與說明
數獨為 9×9 網格分 9 個 3×3 宮,約束為每行、每列、每宮均含 1 至 9 且不重複;生成時先按回溯法填滿合法終盤(每格依次試 1 至 9 並校驗約束),再按所選難度挖空並保留合法終盤作為參考答案;本頁不校驗挖空後是否唯一解。求解用回溯加候選數剪枝。

📚 深度解析:數獨生成/求解器

💡 常見使用場景

  • 休閒練習:選難度一鍵生成題目,附參考答案。
  • 求解輔助:貼上卡住的題目,工具回溯求解給出完整盤。
  • 教學演示:理解約束滿足與回溯演算法。
方法(生成與求解)
9×9 盤面,生成時按難度挖空,附該終盤的參考答案(不保證唯一解);求解用回溯法逐格試數滿足行/列/宮不重複。
算例(演示)
難度對應挖空數:簡單 36 格、中等 44、困難 52(共 81 格)。合法完整數獨盤面約 6.67×10²¹ 種;生成器保留隨機合法終盤作參考答案,不校驗挖空後是否唯一解。

❓ 常見問題(FAQ)

生成的題一定唯一解嗎?
不保證。生成題目由隨機挖空得到,可能存在多個合法填法;貼上求解時回溯給出其中一個合法填法,不做唯一性校驗。
能自己調難度嗎?
可通過挖空數選難度;已知數越少推理難度越高,也越容易出現多解。

Formula & Standard References

Item Formula / Note Source / Standard
Latin square every row, column and box holds the digits one to nine once Sudoku mathematics
Minimum clues a unique puzzle needs at least seventeen clues McGuire et al. 2012
Difficulty difficulty follows the reasoning techniques required, not clue count Sudoku mathematics
⚠️ 使用說明與注意事項