test_utils.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:matchpy 作者: HPAC 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号