Soo... I'm trying to solver Problem n. 8 in Project Euler's site (https://projecteuler.info/problem=8) and I was wondering if there is a cleaner way to write this if condition
n="7316717653..." # there are 1000 digits
(https://projecteuler.info/problem=8)
Max=0
s=[int(s) for s in n]
for i in range(len(s)-3):
if s[i]*s[i+1]*s[i+2]*s[i+2] > Max:
Max=s[i]*s[i+1]*s[i+2]*s[i+3]
print(Max)
# In particular
if s[i]*s[i+1]*s[i+2]*s[i+2] > Max:
Max=s[i]*s[i+1]*s[i+2]*s[i+3]
How could I write this better (I must write it also as if s[i]*s[i+1]*s[i+2]*s[i+2]*s[i+3]...*s[i+13] so it would be nice to find a better way.. Thank you in advance!
Edit: I wrote the post very badly... sorry.
I meant:
Can i write if s[i]*s[i+1]*s[i+2]*s[i+3]*s[i+4]*s[i+5]*s[i+6]*s[i+7]*s[i+8]*s[i+9]*s[i+10]*s[i+11]*s[i+12]*s[i+13] > Max:
or as suggested (better, thank you)
Max=max(Max,s[i]*s[i+1]*s[i+2]*s[i+3]*s[i+4]*s[i+5]*s[i+6]*s[i+7]*s[i+8]*s[i+9]*s[i+10]*s[i+11]*s[i+12]*s[i+13])
In a better way? Like with an automated way of doing s[i+n] 13 or whatever times. Sorry for my bad english.
Edit 2: You answered when I was editing, thank to all of you!