コード例 #1
0
    def test_solve_N_x_N(self, board_size, nb_soluce):
        board = generate_board(board_size)
        boards = solve_n_queen_all_soluce(board_size, board)
        assert len(boards) == nb_soluce

        for soluce in boards:
            is_a_soluce, nb_queen = is_soluce(board_size, soluce)
            assert is_a_soluce
            assert nb_queen == board_size
コード例 #2
0
    def test_solve_four_x_four(self):
        board_size = 4
        board = generate_board(board_size)
        board, solved = solve_n_queen_small(board_size, board)
        assert solved

        is_a_soluce, nb_queen = is_soluce(board_size, board)
        assert is_a_soluce
        assert nb_queen == board_size
コード例 #3
0
    def test_solve_N_x_N_with_small_func(self, board_size):
        board = generate_board(board_size)

        t1 = time.time()
        board, solved = solve_n_queen_small(board_size, board)
        assert solved
        t2 = time.time()
        print(f"\nTest of size {board_size} took {t2-t1} seconds to be solved")

        is_a_soluce, nb_queen = is_soluce(board_size, board)
        assert is_a_soluce
        assert nb_queen == board_size
コード例 #4
0
 def test_is_not_soluce(self):
     board = self.get_wrong_board_full()
     is_a_soluce, nb_queen = is_soluce(4, board)
     assert not is_a_soluce
     assert nb_queen == 4
コード例 #5
0
 def test_is_soluce_not_full(self):
     board = self.get_good_board_not_full()
     is_a_soluce, nb_queen = is_soluce(4, board)
     assert not is_a_soluce
     assert nb_queen == 3
コード例 #6
0
 def test_is_soluce_soluce(self):
     board = self.get_board_soluce()
     is_a_soluce, nb_queen = is_soluce(4, board)
     assert is_a_soluce
     assert nb_queen == 4
コード例 #7
0
 def test_is_soluce_empty(self):
     board = generate_board(4)
     is_a_soluce, nb_queen = is_soluce(4, board)
     assert not is_a_soluce
     assert nb_queen == 0