#!/usr/bin/python
import sys
def getMax(array):
maxV=None;
maxL=[]
start = 0
end = 0
for n in range(len(array)):
l=[]
v=0
for i in array[n:]:
l=l[:]
l.append(i)
v=v+i
if(v>maxV or maxV==None):
maxV=v
maxL=l
start = n
end = n+array[n:].index(i)
print("Start: %s, End: %s" % (start, end))
print(maxV)
def getMax2(array):
tempSum = None
Sum = None
start = 0
end = 0
tempStart = 0
for n in range(len(array)):
if tempSum>0 or tempSum>array[n]:
tempSum = tempSum+array[n]
else:
tempSum = array[n]
tempStart = n
if tempSum>Sum:
start = tempStart
Sum=tempSum
end = n
#print(array[start:end+1])
print("Start: %s, End: %s" % (start, end))
print(Sum)
if __name__=="__main__":
getMax([int(x) for x in sys.argv[1].split(",")])
|