N-queens problem: Difference between revisions

m
→‎Python: backtracking on permutations: Variable l replaced by h (1 and l look too similar in the source code)
m (→‎Python: backtracking on permutations: Variable l replaced by h (1 and l look too similar in the source code))
Line 12,870:
if i < n:
for k in range(i, n):
lh, j = a[i], a[k]
if b[i + j] and c[i - j]:
a[i], a[k] = j, lh
b[i + j] = c[i - j] = False
yield from queen(i + 1)
b[i + j] = c[i - j] = True
a[i], a[k] = lh, j
else:
yield a
Line 12,898:
if i < n:
for k in range(i, n):
lh, j = a[i], a[k]
a[i], a[k] = j, lh
if b[i + j] and c[i - j]:
b[i + j] = c[i - j] = False
305

edits