def queens_problem(n): board = make_board(n) return conjoin( flatten(exactly_one(row) for row in board), flatten(at_most_one(col) for col in transpose(board)), flatten(at_most_one(diag) for diag in rising_diagonals(board)), flatten(at_most_one(diag) for diag in falling_diagonals(board)))
def add_permutation(slots): for variables in transpose(slots): problem.extend(at_most_one(variables))