def test_completeness_and_uniqueness(self, n, m):
solutions = set(weak_composition_iter(n, m))
if m == 0 and n > 0:
expected_count = 0
else:
# the total number of distinct partitions is given by (n+m-1)!/((m-1)!*n!)
expected_count = 1
for i in range(1, m):
expected_count *= n + m - i
for i in range(1, m):
expected_count /= i
assert len(solutions) == expected_count
assert len(set(solutions)) == expected_count
评论列表
文章目录