bounslay

Untitled

May 12th, 2023
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.52 KB | None | 0 0
  1. # Print "yes" if the array is in Wave Form - e.g. first > second < third > fourth < fifth >
  2. # Print "no" if the array is not in Wave Form
  3.  
  4. usr_inp = input().split()
  5. numbers = [int(i) for i in usr_inp]
  6.  
  7. # 2 1 2 1 2 1 2
  8. # 7 3 5 2 8 4
  9. # 22 34 12 523 122 4444 123
  10.  
  11. res = 'yes'
  12.  
  13. for i in range(1, len(numbers)-1):
  14.     if (numbers[i] >= numbers[i-1]) and (numbers[i] <= numbers[i+1]):
  15.         res = 'no'
  16.    
  17.     elif (numbers[i] <= numbers[i-1]) and (numbers[i] >= numbers[i+1]):
  18.         res = 'no'
  19.    
  20.  
  21. print(res)
Advertisement
Add Comment
Please, Sign In to add comment