import time #http://www.maths.nuigalway.ie/ #~gettrick/teach/cs209/ #p=[23,45,-31,-3,89,7,4,-2,4,56,-227,43] #p=[2,4,-5,6] #p=[-3,-56,-38] p=[-2,-4,45,3,-7] #p=[65,-2,-3,-4,-5,77] #there are errors in this program - try to #spot them! n=range(len(p)) prof=0 start= time.clock() for i in n: for j in n: block=0 for k in n[i:j]: block=block+p[k] print n[i:j] print 'profit',block if block>prof: prof=block buy=n[i:j] print time.clock()-start print prof print buy