Ejemplo n.º 1
0
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)))
Ejemplo n.º 2
0
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)))
Ejemplo n.º 3
0
 def add_permutation(slots):
     for variables in transpose(slots):
         problem.extend(at_most_one(variables))
Ejemplo n.º 4
0
 def add_permutation(slots):
     for variables in transpose(slots):
         problem.extend(at_most_one(variables))