Jump to content

N-queens problem: Difference between revisions

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
<lang python># From: http://wiki.python.org/moin/SimplePrograms, with permission from the author, Steve Howell
BOARD_SIZE = 8
 
def under_attack(col, queens):
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.