N-queens problem: Difference between revisions
m
→Python: Niklaus Wirth algorithm: Revised explanation
m (→Python: Niklaus Wirth algorithm: Revised one sentence) |
m (→Python: Niklaus Wirth algorithm: Revised explanation) |
||
Line 12,841:
for solution in queens(8, 0, [], [], []):
print(solution)</syntaxhighlight>
The algorithm can be easily improved by using O(1) sets instead of O(n) lists and by avoiding the
<syntaxhighlight lang="python">def queens(n: int):
|