RosettaCodeData/Task/N-queens-problem/Python/n-queens-problem-1.py

9 lines
204 B
Python

from itertools import permutations
n = 8
cols = range(n)
for vec in permutations(cols):
if n == len(set(vec[i]+i for i in cols)) \
== len(set(vec[i]-i for i in cols)):
print ( vec )