Project Euler: problem 8
Posted
by
Marijus
on Stack Overflow
See other posts from Stack Overflow
or by Marijus
Published on 2010-12-13T16:53:31Z
Indexed on
2011/06/30
8:22 UTC
Read the original article
Hit count: 161
python
|project-euler
n = # some ridiculously large number, omitted
N = [int(i) for i in str(n)]
maxProduct = 0
for i in range(0,len(N)-4):
newProduct = 1
is_cons = 0
for j in range(i,i+4):
if N[j] == N[j+1] - 1:
is_cons += 1
if is_cons == 5:
for j in range(i,i+5):
newProduct *= N[j]
if newProduct > maxProduct:
maxProduct = newProduct
print maxProduct
I've been working on this problem for hours now and I can't get this to work. I've tried doing this algorithm on paper and it works just fine.. Could you give me hints what's wrong ?
© Stack Overflow or respective owner