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

9 lines
204 B
Python
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
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 )