def greatest_prod(digits, n):
    """ Find the `n` adjacent digits in `digits` with the greatest product. """
    # Calculate the product of the first `n` digits.
    prod = 1
    zero_cnt = 0
    for c in digits[:n]:
        d = int(c)
        if d > 1:
            prod *= d
        elif d == 0:
            zero_cnt += 1
    max_prod = prod

    # Evaluate all other products.
    for i in range(1, len(digits) - n + 1):
        # Divide by the left-most digit/factor of the previous product.
        left = int(digits[i - 1])
        if left > 1:
            prod /= left
        elif left ==0:
            zero_cnt -= 1

        # Multiply by our new right-most digit.
        right = int(digits[i + n - 1])
        if right > 1:
            prod *= right
        elif right == 0:
            zero_cnt += 1

        # As long as there are zeros within our `n` adjacent digits,
        # our product is 0 and should be ignored.
        if zero_cnt == 0:
            max_prod = max(max_prod, prod)

    return int(max_prod)