Python/project_euler/problem_08/sol1.py
Sanders Lin 9417091dab Update sol1.py (#643)
small off by one error. Boundary condition: if len(number) =13 , we would need to check exactly 1 combination, namely number itself. However  for i in range(len(number)-13): will iterate 0 times.
2019-02-13 18:02:32 +08:00

16 lines
348 B
Python

import sys
def main():
LargestProduct = -sys.maxsize-1
number=input().strip()
for i in range(len(number)-12):
product=1
for j in range(13):
product *= int(number[i+j])
if product > LargestProduct:
LargestProduct = product
print(LargestProduct)
if __name__ == '__main__':
main()