Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
def largest_product(num_string, series):
if series == 0:
return 1
end = series
products = []
for n in range(len(num_string)):
selection = num_string[n:end]
if len(selection) != series: break
product = 1
for num in selection:
i = int(num)
if i > 0:
product *= i
else:
product = 0
products.append(product)
end += 1
return max(products)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment