Esempio n. 1
0
def test_solution_to_split_problem_solves_original_problem(a, n):
    try:
        result = list(split_problem(a, n))
        for sub in result:
            s = get_exact_cover(sub)
            if s.size > 0:
                assert is_solution(s, sub)
                assert is_solution(s, a)
    except NoSolution:
        assert True
    except CannotSplitFurther:
        assert True
Esempio n. 2
0
def test_solve_very_hard_sudoku_problem_2():
    matrix = load_problem("tests/files/very_hard_sudoku_2.csv")
    solution = get_exact_cover(matrix)
    assert is_solution(solution, matrix)
Esempio n. 3
0
def test_solve_medium_sudoku_problem():
    matrix = load_problem("tests/files/medium_sudoku.csv")
    solution = get_exact_cover(matrix)
    assert is_solution(solution, matrix)
Esempio n. 4
0
def test_is_solution_fails_for_proper_subset(a):
    s = get_exact_cover(a)
    assert not is_solution(s[:-1], a)
Esempio n. 5
0
def test_is_solution_fails_for_extra_rows(a, x):
    s = get_exact_cover(a)
    assert not is_solution(list(s) + [x], a)
Esempio n. 6
0
def test_list_is_solution(a):
    s = list(get_exact_cover(a))
    assert is_solution(s, a)
Esempio n. 7
0
def test_is_solution(a):
    s = get_exact_cover(a)
    assert is_solution(s, a)