Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Decreasing-increasing order drill
- function IsInDecreasingOrder(dx::Array{Int64, 1})
- OK = false
- for d in dx
- if d > 0; return false; end
- if d < 0; OK = true; end
- end
- return OK
- end
- function IsInIncreasingOrder(dx::Array{Int64, 1})
- OK = false
- for d in dx
- if d < 0; return false; end
- if d > 0; OK = true; end
- end
- return OK
- end
- function main(x::Array{Int64, 1})
- dx = diff(x)
- for i = 1:(length(dx)-1)
- dx1 = dx[1:i]
- if IsInDecreasingOrder(dx1)
- dx2 = dx[(i+1):end]
- if IsInIncreasingOrder(dx2); return true, x[i]; end
- end
- end
- return false, NaN
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement