__main__.py 文件源码

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

项目:CNValloc 作者: m1m0r1 项目源码 文件源码
def combinations_with_replacement(iterable, r):
        """
        >>> list(combinations_with_replacement('AT', 2))
        [('A', 'A'), ('A', 'T'), ('T', 'T')]
        """
        assert isinstance(r, (int, long))
        assert r >= 0

        if r == 0:
            yield ()
        else:
            alls = list(iterable)
            for (i, el) in enumerate(alls):
                for els in combinations_with_replacement(alls[i:], r - 1):
                    yield (el,) + els
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号