|
1
2
3
4
|
#!/usr/bin/python
import sys;
import math;
|
|
5
|
import os
|
|
6
|
|
|
7
|
def nDigitProduct(num,offset,digits):
|
|
8
9
|
sum = 1;
|
|
10
|
for i in range(offset,offset+digits):
|
|
11
12
13
14
|
sum *= int(num[i]);
return sum;
|
|
15
|
def greatestProduct(num,digits):
|
|
16
17
|
higherProduct = 0;
|
|
18
19
|
for i in range (0, len(num)-(digits-1)):
product = nDigitProduct(num,i,digits);
|
|
20
21
22
23
24
|
if(product > higherProduct):
higherProduct = product;
return higherProduct;
|
|
25
26
27
|
strNum = "".join(sys.stdin.readlines()).replace('\n','')
numDigits = int(sys.argv[1])
print "Result is: " + str(greatestProduct(strNum,numDigits));
|