| 1 | 1 | def largest_product(series: str, size: int) -> int: |
| 2 | pass | |
| 2 | # Edge Case: negative span value | |
| 3 | if size < 0: | |
| 4 | raise ValueError("span must not be negative") | |
| 5 | ||
| 6 | # Edge Case: span length exceeds input length | |
| 7 | if size > len(series): | |
| 8 | raise ValueError("span must not exceed string length") | |
| 9 | ||
| 10 | # Edge Case: empty input string with zero span | |
| 11 | if size == 0: | |
| 12 | return 1 | |
| 13 | ||
| 14 | # Edge Case: non-digit characters in input | |
| 15 | if not series.isdigit(): | |
| 16 | raise ValueError("digits input must only contain digits") | |
| 17 | ||
| 18 | max_product = 0 | |
| 19 | for i in range(len(series) - size + 1): | |
| 20 | substring = series[i:i+size] | |
| 21 | product = 1 | |
| 22 | for digit in substring: | |
| 23 | product *= int(digit) | |
| 24 | if product > max_product: | |
| 25 | max_product = product | |
| 26 | ||
| 27 | return max_product | |
| 28 | ||
| 29 | # Handled Edge Cases: negative span value, span length exceeds input length, empty input string with zero span, non-digit characters in input |