小编far*_*ter的帖子

简单回溯暴力算法最坏情况下有效的数独谜题是什么?

数独的“简单/朴素回溯强力算法”、“直接深度优先搜索”是众所周知并已实现的。

并且似乎不存在不同的实现。(当我第一次写这个问题时..我想说我们可以完全标准化它,但措辞很糟糕..)

我认为这个人很好地描述了该算法:/sf/answers/145284891/

编辑:所以让我用伪代码更详细地说明它......

var field[9][9]
set the givens in 'field'
if brute (first empty grid) = true then
    output solution
else
    output no solution
end if

function brute (cx, cy)
    for n = 1 to 9
        if (n doesn't present in row cy) and (n doesn't present in column cx) and (n doesn't present in block (cx div 3, cy div 3)) then
            let field[cx][cy] = n
            if (cx, cy) this is the last empty grid …
Run Code Online (Sandbox Code Playgroud)

puzzle algorithm recursion sudoku time-complexity

5
推荐指数
1
解决办法
2326
查看次数

标签 统计

algorithm ×1

puzzle ×1

recursion ×1

sudoku ×1

time-complexity ×1