# -*- coding: utf-8 -*-
def puzzle(rows, cols):
if rows == 0:
return [[]]
else:
return new_queen(rows - 1, cols, puzzle(rows - 1, cols))
def new_queen(new_row, cols, plsd_queens):
new_solutions = []
for solution in plsd_queens:
for new_col in range(cols):
if test(new_row, new_col, solution):
new_solutions.append(solution + [new_col])
return new_solutions
def test(new_row, new_col, solution):
for row in range(new_row):
if solution[row] == new_col or solution[row] + row == new_col + new_row or\
solution[row] - row == new_col - new_row:
return False
return True
Hello all! How can I find the unique solutions of this recursive algorithm of N-queens puzzle? It finds only all solutions: on board 8x8 it will be 92 solutions, but unique is only 12 (the other solutions are translations and mirrored from this 12)