largest_series_product.py 文件源码

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

项目:exercism-python 作者: unfo 项目源码 文件源码
def largest_product(txt, n):
    if len(txt) < n or n < 0:
        raise ValueError("Input length is less than n")

    if any(not c.isdigit() for c in txt):
        raise ValueError("Input must be numeric")

    if n == 0:
        return 1

    products = [reduce(mul, grp) for grp in slices(txt, n)]
    largest = reduce(max, products)

    return largest


# from series.py
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号