RosettaCodeData/Task/N-queens-problem/Python/n-queens-problem-1.py
Ingy döt Net b83f433714 tasks a-s
2013-04-10 23:57:08 -07:00

8 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 )