Anonymous user
N-queens problem: Difference between revisions
→Simple Backtracking Solution
Line 3,361:
A surprisingly simple change to the above code (changing the list comprehension to a generator expression) produces a backtracking solution:
{{works with|Python|2.6, 3.x}}
<lang python>BOARD_SIZE = 8▼
▲BOARD_SIZE = 8
def under_attack(col, queens):
|