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
评论列表
文章目录