skioe

gori(n)

Feb 10th, 2021 (edited)
592
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.36 KB | None | 0 0
  1. heights = []
  2. for i in iter(input, "0"):
  3.     heights.append(int(i))
  4.  
  5. indexes = []
  6. for point in range(1, len(heights) - 1):
  7.     if heights[point - 1] < heights[point] and heights[point] > heights[point + 1]:
  8.         indexes.append(point)
  9.  
  10. try:
  11.     print(min(filter(lambda x : x > 0, (x-y for x in indexes for y in indexes))))
  12. except ValueError:
  13.     print(0)
  14.  
Advertisement
Add Comment
Please, Sign In to add comment