Update n_queens code.

This commit is contained in:
krahets
2023-06-21 02:56:28 +08:00
parent ba1e5c1d7d
commit 9fc1a0b2b3
8 changed files with 16 additions and 16 deletions

View File

@@ -16,8 +16,8 @@ func backtrack(row: Int, n: Int, state: inout [[String]], res: inout [[[String]]
// 线线
let diag1 = row - col + n - 1
let diag2 = row + col
// ( 线 线)
if !(cols[col] || diags1[diag1] || diags2[diag2]) {
// 线线
if !cols[col] && !diags1[diag1] && !diags2[diag2] {
//
state[row][col] = "Q"
cols[col] = true