from functools import reduce


def largest_product(series, size):
    """
    return the largest product of `size` consecutive digits fron `series`
    """
    if size < 0:
        raise ValueError

    def product(digits):
        """
        return the product of the numbers in a string of `digits`
        """
        return reduce(lambda x, y: x * int(y), digits, 1)

    def generate_slice():
        """
        generate substrings of `series` that are `size` digits long
        """
        ii = len(series) - size
        while ii >= 0:
            yield series[ii : ii + size]
            ii -= 1

    return max(product(slice) for slice in generate_slice())