Advertisement
Guest User

Untitled

a guest
Sep 29th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. lst = [0, 1, 2, 3, 0, 5, 9, 0, 0, 0, 11, 1, 2, 0, 0, 0, 0, 2, 11, 15, 0, 0, 0, 0, 0, 0]
  2. # 0 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
  3.  
  4. maxi = 0
  5. now = 0
  6. best_ind = -1
  7. prew_ind = -1
  8. next_ind = 1
  9. while next_ind < len(lst):
  10. if lst[next_ind] == 0:
  11. now += 1
  12. next_ind += 1
  13. else:
  14. if maxi < now:
  15. maxi = now
  16. best_ind = prew_ind
  17. now = 0
  18. prew_ind = next_ind
  19. next_ind += 1
  20.  
  21. if next_ind == len(lst):
  22. maxi = now
  23. best_ind = prew_ind
  24.  
  25. print(maxi, best_ind + 2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement