Exemplo n.º 1
0
def calculate_solution(pieces, full_board, short_board, save_db, get_db):
    """The eight queens puzzle in Python."""
    t = time.process_time()

    queens = NQueens(pieces, full_board, short_board, save_db, get_db)
    solutions = queens.solve()
    print(f"Found {solutions} solutions.")

    elapsed_time = timedelta(seconds=time.process_time() - t)
    print(f"Time elapsed (hh:mm:ss.ms) {elapsed_time}")
Exemplo n.º 2
0
def test_one_queen():
    pieces = 1
    queens = NQueens(pieces)
    solutions = queens.solve()
    assert solutions == 1
Exemplo n.º 3
0
def test_twelve_queens():
    pieces = 12
    queens = NQueens(pieces)
    solutions = queens.solve()
    assert solutions == 14200
Exemplo n.º 4
0
def test_eleven_queens():
    pieces = 11
    queens = NQueens(pieces)
    solutions = queens.solve()
    assert solutions == 2680
Exemplo n.º 5
0
def test_ten_queens():
    pieces = 10
    queens = NQueens(pieces)
    solutions = queens.solve()
    assert solutions == 724
Exemplo n.º 6
0
def test_nine_queens():
    pieces = 9
    queens = NQueens(pieces)
    solutions = queens.solve()
    assert solutions == 352
Exemplo n.º 7
0
def test_eigth_queens():
    pieces = 8
    queens = NQueens(pieces)
    solutions = queens.solve()
    assert solutions == 92
Exemplo n.º 8
0
def test_seven_queens():
    pieces = 7
    queens = NQueens(pieces)
    solutions = queens.solve()
    assert solutions == 40
Exemplo n.º 9
0
def test_six_queens():
    pieces = 6
    queens = NQueens(pieces)
    solutions = queens.solve()
    assert solutions == 4
Exemplo n.º 10
0
def test_five_queens():
    pieces = 5
    queens = NQueens(pieces)
    solutions = queens.solve()
    assert solutions == 10
Exemplo n.º 11
0
def test_four_queens():
    pieces = 4
    queens = NQueens(pieces)
    solutions = queens.solve()
    assert solutions == 2
Exemplo n.º 12
0
def test_three_queens():
    pieces = 3
    queens = NQueens(pieces)
    solutions = queens.solve()
    assert solutions == 0
Exemplo n.º 13
0
def test_two_queens():
    pieces = 2
    queens = NQueens(pieces)
    solutions = queens.solve()
    assert solutions == 0