def test_completeness(self, coeffs, c): self._limit_possible_solution_count(coeffs, c) solutions = set(solve_linear_diop(c, *coeffs)) values = [range(c // x) for x in coeffs] for solution2 in itertools.product(*values): result = sum(c * x for c, x in zip(coeffs, solution2)) if result == c: assert solution2 in solutions, "Missing solution {!r}".format(solution2)
def test_correctness(self, coeffs, c): self._limit_possible_solution_count(coeffs, c) for solution in solve_linear_diop(c, *coeffs): assert len(solution) == len(coeffs), "Solution size differs from coefficient count" result = sum(c * x for c, x in zip(coeffs, solution)) for x in solution: assert x >= 0 assert result == c, "Invalid solution {!r}".format(solution)
def test_uniqueness(self, coeffs, c): self._limit_possible_solution_count(coeffs, c) solutions = list(solve_linear_diop(c, *coeffs)) assert is_unique_list(solutions), "Duplicate solution found"