Given a list of positive integers determine if there is an element that is either greater than its two neighbors or less than its two neighbors (a "bump"). To be clear a bump can never be the first or last item of the list because they only have one neighbor.
Your program should output one of two consistent values each corresponding to either a list with no bumps or a list with bumps. What the values are is unimportant you may choose them yourself.
This is code-golf so answers will be scored in bytes with fewer bytes being better.
Test cases
[] -> False
[1] -> False
[1,2] -> False
[1,2,1] -> True
[1,2,2] -> False
[1,2,3] -> False
[1,2,2,1] -> False
[1,2,2,3] -> False
[1,2,1,2] -> True
[1,3,2] -> True
[3,1,2] -> True
[2,2,2] -> False
[1,3,3]
(ensures that answers using Dennis's algorithm take the sign of the increments rather than just using the increments themselves) \$\endgroup\$[1,2,2]
? Or am I missing something? \$\endgroup\$[1,2,2]
are the same as the signs of those deltas but that's not the case with[1,3,3]
. \$\endgroup\$