princennamdi

Stock(with indexes)

Nov 15th, 2012
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.39 KB | None | 0 0
  1. num = raw_input("Enter Stock numbers: ").split(" ")
  2. z=len(num)
  3. def GMP(n):
  4.     least=0
  5.     profit=0
  6.     index=0
  7.     for i in range(z):
  8.         profit += int(n[i])
  9.         if least>profit:
  10.                 least=profit
  11.                 end=i
  12.         else:
  13.             if profit >= 0:
  14.                 profit=0
  15.                 index= i+1
  16.     return least, index, end
  17. print GMP(num)
Advertisement
Add Comment
Please, Sign In to add comment