You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
func backtrace(_ start:Int) -> Bool {
for i in start..<81 {
let row = i/9
let col = i%9
guard board[row][col] == "." else { continue }
for j in 1...9 {
let val = Character("\(j)")
if isVaild(row, col, val, board) {
board[row][col] = val
if backtrace(i+1) { return true }
board[row][col] = "."
}
}
return false
}
return true
}
The text was updated successfully, but these errors were encountered:
数独由于是个规则矩阵,所以可以使用/%来实现降维,并且因为降成一维了,我们就可以使用startIndex来实现剪枝(之前填写过的肯定有数字就不需要进循环了)
以下是swift的代码
The text was updated successfully, but these errors were encountered: