fork download
  1. def main
  2. arr = [1,2,3,-1,-4,-5,-10,-31]
  3. i = 1
  4. n = arr.length
  5. while i < n and arr[i] > arr[i-1]
  6. i += 1
  7. end
  8.  
  9. if i == 1 or i == n
  10. p "Not Mountain!"
  11. else
  12. if arr[i] < arr[i-1]
  13. flag = 1
  14. for k in i..n - 1
  15. if arr[k] > arr[k-1]
  16. flag = 0
  17. end
  18. end
  19. if flag == 1
  20. p "Mountain!"
  21. else
  22. p "Not Mountain!"
  23. end
  24. end
  25. end
  26. end
  27. main
  28.  
Success #stdin #stdout 0.01s 6156KB
stdin
Standard input is empty
stdout
"Mountain!"