Advertisement
Guest User

Untitled

a guest
Apr 1st, 2020
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. l1 = [int(i) for i in input().split()]
  2. mnln = 0
  3. for i in range(len(l1)):
  4. if l1[i] == 1:
  5. ln1 = 0
  6. ln2 = 0
  7. t = False
  8. t1 = False
  9. y = i - 1
  10. while(y >= 0) and (l1[i] != 2):
  11. ln1 += 1
  12. if l1[y] == 2:
  13. t = True
  14. break
  15. y -= 1
  16. y = i + 1
  17. while (y < len(l1)) and (l1[i] != 2):
  18. ln2 += 1
  19. if l1[y] == 2:
  20. t1 = True
  21. break
  22. y += 1
  23. if t1:
  24. if not t or ln1 > ln2:
  25. ln1 = ln2
  26. mnln = max(ln1, mnln)
  27. print(mnln)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement