[Question]
  [
# Challenge
Given a list, determine if grouping the list into runs of increasing and decreasing elements will result in a list of equal-sized lists.
In other words, "turning points" of the list are spaced out evenly.
# Example
Here's an example: `0, 3, 7, 5, 2, 3, 6`
`0, 3, 7` increases, `7, 5, 2` decreases, and `2, 3, 6` increases. Therefore this is truthy.
Another example: `1, 4, 6, 8, 5, 3, 5, 7, 9`
`1, 4, 6, 8` increases, `8, 5, 3` decreases, and `3, 5, 7, 9` increases. Therefore this is falsy.
# Rules and Specifications
* No adjacent elements will be equal
* All numbers can be assumed to be within your language's reasonable number range
* You may assume that all numbers are integers, if it helps you golf your submission
* This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the shortest answer wins
* Input as a list in any reasonable representation and output as any truthy/falsy value. The two values must be consistent.
# Test Cases
```
Input -> Output
1, 3, 5, 8, 6, 4, 2, 3, 5, 7, 6, 4, 2, 5, 7, 9, 6, 4, 2 -> True
1, 3, 5, 7, 6, 4, 5, 7, 9, 8, 6, 4, 2, 3, 5 -> False
2, 3, 6, 4, 2, 3, 7, 5, 3, 4, 6 -> True
3, 6, 4, 8, 5, 7, 3, 5, 2 -> True
8 -> True
1, 3, 5, 7 -> True
4, 5, 7, 6, 8, 9 -> False
6, 4, 2, 3, 5, 4, 2 -> True
8, 5, 3, 2, 4, 6, 5, 3, 2, 5, 7 -> False
```
**Note**: You may not assume that all numbers are single digits (unless that is all your language is capable of handling); the test cases reflect that just because it's easier for me to type the cases this way :P Here are a few test cases with numbers outside of that range:
```
1, 5, 10, 19, 15, 13, 8, 13, 18, 23, 19, 18, 14 -> True
15, 14, 17, 16, 19, 18 -> True
12, 16, 19, 15, 18, 19 -> False
```
  
[Answer]
# [MATL](https://github.com/lmendo/MATL), ~~10~~ 9 bytes
```
dZS&Y'da~
```
[Try it online!](https://tio.run/##y00syfn/PyUqWC1SPSWx7v//aCMdBWMdBTMdBRMdBQjbXEfBFMwAipjFAgA "MATL – Try It Online")
Saved one byte thanks to Luis Mendo! 
### Explanation:
Assume the input is: `[0, 3, 7, 5, 2, 3, 6]`:
```
            % Implicit input:                                [0, 3, 7, 5, 2, 3, 6]
d           % Difference between adjacent elements:          [3, 4, -2, -3,  1,  3]
 ZS         % Sign of the differences:                       [1, 1, -1, -1, 1, 1]
   &Y'      % Length of runs of consecutive elements:        [2, 2, 2]
     d      % Difference between the lengths:                [0, 0]
      a     % Any non-zero elements:                         False
       ~    % Negate, to get a truthy value if all are zero: True
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 6 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
IṠŒgAE
```
[Try it online!](https://tio.run/##y0rNyan8/9/z4c4FRyelO7r@//8/2lBHwUhHwVhHAcgw0FEw1VGw0FEwA4sg2LEA "Jelly – Try It Online")
Saved 1 byte thanks to [Adnan](https://codegolf.stackexchange.com/users/34388/adnan)!
## How it works
```
IṠŒgAE  - Full program.
I       - Increments (Deltas).
 Ṡ      - Sign of each. -1 if negative, 0 if null, 1 if positive.
  Œg    - Group runs of adjacent elements.
    A   - Absolute value. Vectorizes. This maps -1 and 1 to the same value.
     E  - Are all equal?
```
While golfing, I discovered some cool, longer alternatives: `IṠŒgL€E`, `IṠŒrṪ€E` (uses run-length-encode instead).
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 38 bytes
```
Equal@@(1^Differences@#~SplitBy~Sign)&
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78n2ar8d@1sDQxx8FBwzDOJTMtLbUoNS85tdhBuS64ICezxKmyLjgzPU9T7b@mNVdAUWZeiUOaQ7WhjoKpjoKhARBbAjGIbayjYAGhDIG0kTFUCiRmUvsfAA "Wolfram Language (Mathematica) – Try It Online")
### Explanation
```
Equal@@(1^Differences@#~SplitBy~Sign)&  (* Input:                {3, 6, 4, 8, 5, 7, 3, 5, 2} *)
          Differences@#                 (* Take differences:     {3, -2, 4, -3, 2, -4, 2, -3} *)
                       ~SplitBy~Sign    (* Split by sign:        {{3}, {-2}, {4}, {-3}, {2}, {-4}, {2}, {-3}} *)
        1^                              (* Raise to power of 1:  {{1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}} *)
Equal@@                                 (* Check equal:          True *)
```
[Answer]
# [Octave](https://www.gnu.org/software/octave/), ~~54~~ 50 bytes
```
@(x)nnz(unique(diff(find([diff(diff(x)>0) 1]))))<2
```
[**Try it online!**](https://tio.run/##XY9NCsIwEIX3PcUsExiK/bFN0Yr3KF1Im0CgRMVGiuLZY0xojM4izHzz5j1yHubTnRvRpmlqjmShSj2IVvKqORmlEERINZLOte5Z6GFDIeuprX1upLro@QYtPLsMoUDYIjCECqFEyFdSR8SPTSB98r0MuiD697Jq38W0dgeFI5VVhDVbnbz9J4v95NmhjJKtvulfu2Tg0yS0IgLBf5CaNw)
### Explanation
```
@(x)nnz(unique(diff(find([diff(diff(x)>0) 1]))))<2
@(x)                                                % Define anonymous function    
                               diff(x)              % Deltas (consecutive differences)
                                      >0            % Positive? Gives signs
                          diff(         )           % Deltas between signs
                         [                1]        % Append 1 to "close" last group
                    find(                   )       % Indices of nonzeros
               diff(                         )      % Deltas. Gives group lengths
        unique(                               )     % Remove duplicates
    nnz(                                       )    % Number of nonzeros. Gives length
                                                <2  % If 1 or 0: input is periodic
```
[Answer]
## R, 36 bytes
```
function(n)!sd(rle(sign(diff(n)))$l)
```
`diff` computes the successive differences, then `sign` squishes those down to ±1. `rle` then run-length encodes them. All the elements of this `rle` should be the same, i.e. the vector has standard deviation zero. `!` then produces the correct logical output.
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), ~~8~~ 7 bytes
```
¥0.SγaË
```
[Try it online!](https://tio.run/##MzBNTDJM/f//0FIDveBzmxMPd///H22oo2Cqo2BoAMSWQAxiG@soWEAoQyBtZAyVAomZxwIA "05AB1E – Try It Online")
-1 thanks to Adnan.
[Answer]
# [C (gcc)](https://gcc.gnu.org/), ~~143~~ ~~140~~ ~~138~~ ~~136~~ ~~135~~ 132 bytes
* Saved three bytes; using a variable `r` to store the function's return boolean instead of terminating using `return`.
* Saved two bytes; golfing `int A[]` to `int*A` (using a pointer instead of an array).
* Saved two bytes thanks to [Steadybox](https://codegolf.stackexchange.com/users/61405/steadybox); golfing `f(int*A,int a)` to `f(A,a)int*A;`.
* Saved a byte; golfing `if(d!=...` to `if(d-...`.
* Saved three bytes; golfing `;j++...j+1` to `;...++j`.
```
j,d,e,l,m,r;f(A,a)int*A;{for(d=A[0]>A[1],r=1,j=m=l=0;j-~-a;){l++;if(d-(e=A[j]>A[++j]))d=e,j--,r*=l>=(m=!m?l:m),l=0;}r*=-~l==m||m<1;}
```
[Try it online!](https://tio.run/##nZRNc5swEIbPza/Y@gS2SJD4DlUyPviaU2@MDxobt2bA7gC9xHH@urtCXoY6NONaF2Al7aN3Wb0r58dqdToVbM1yVrKK1enGmjNlb3ftdJ4eNvvaWst55i6f5hlfslpyVshKltJNC@fdUal9KGezdLux1o6V48pCr5zNiqVtr2XOCsdh9VSWT9Kq5NfquXysbKZ3HzHqvJdSVm9v1TeeHk@V2u4s@3D3BdnwChJ4at7nbsaTJQYOnIHHIGAQMwgZ@AwERaJBxHwmfeSYgs6jXJ0Uw233ksLDdPqApKkEFO0yXGCDlDhNYJ7x4G9wj@kZl0eBwSAw1zzc0eoX9wKMuRU34F6xyDjvwCbpEBB1bK@LhPCPQWChwQhoxYhizKeEAQsCexmYUvfUmLSaAgj4dBDYwxy6Oq03AsZMyjNgj8B@BkZxDDcNAvsarBX7I2CUo3wD9gkcZOBf/OObwIEGI6ANRsCYVQUGHBA4zCDswP6gs7DayX@CQw3GrW040lwYV6EBhwSOMu6RYgRz7Hx9K3SDcq87gn5wfArvPKVj/iU40kJxRRuNKEY5KjLgiMAxKe5QKJvjKh4S42rFMSmOR8B4VBUbcEzgpAeLATA4C0uuBicETkZKjSlVYsDJGbxwB81lrq@4pbly99xcjfsRvMD/lxvnasi5FjyDqANf2KR/5QkIrA1Lt2bDP5Z6gaJy41wNOdeid66YfEoYqxp8fnbHCEzO1YgRxZgjN87VaOf6VeOWjfX6PHnZQ17X@7qBzf73bn0/eZx8/5nXOWwbUDszdz@xcc/d8fQH "C (gcc) – Try It Online")
Defines a function `f` which looks at every element in the list but the last and determines this element's relation to the next element in the list. The number of consecutive equal comparisons is stored the first time the relation flips, any runs after the initial run that differ in length to the stored length result in a falsy output. At the end, the second-to-last element's relation to the last element's is looked at so that it matches the rest of the list.
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), 11 bytes
```
qFlM.g._k.+
```
[Try it here.](http://pyth.herokuapp.com/?code=qFlM.g._k.%2B&input=%5B1%2C+5%2C+10%2C+19%2C+15%2C+13%2C+8%2C+13%2C+18%2C+23%2C+19%2C+18%2C+14%5D&debug=00)
[Answer]
# [Python 2](https://docs.python.org/2/), ~~107~~ ~~105~~ ~~103~~ ~~97~~ ~~96~~ ~~94~~ 91 bytes
```
lambda l:len({sum(g)**2for k,g in groupby(map(cmp,l[:-1],l[1:]))})<2
from itertools import*
```
[Try it online!](https://tio.run/##bU5LDoIwEN17ilm2pCa2ICLRkygL/IDElja1Lozx7DiAkKIumum83zzzcBddi6bY7huZq8MpB5nKc02et7siJQ0CUWgLV1ZCVUNp9d0cHkTlhhyVYXKXznmGg6cZpS@6EbPCagWVO1untbxBpYy2LmiMrWoHBdlxBiGDJYOEQcwgYiAGZOUh/boekYzOfiNGw6j@DvVtPeTTq84ZdkjsS0ddMmT3Byc1kv@dfDTyamLU@suBHF/gw@K8/Yedqh0cpwg/VItFE2srxmyOyTweVBOF8JjlJwPPN28 "Python 2 – Try It Online")
# [Python 3](https://docs.python.org/3/), ~~102~~ ~~100~~ 97 bytes
```
lambda l:len({len([*g])for k,g in groupby(x>y for x,y in zip(l,l[1:]))})<2
from itertools import*
```
[Try it online!](https://tio.run/##dY7NDoIwEITvPsUei9mDpYhg1BdBDxoFGwttak1E47NjC0KoxkP/vp2ZjqrNWVasydfbRuzLw3EPYilOFXm6LZsWuyCXGi5YAK@g0PKmDjW5b2pw@I61ww@uiECR0eUuCF7BKpzkWpbAzUkbKcUVeKmkNtNGaV4ZkpOMIjCEOUKCECNECGFPFiPSPdOB2PjJb8bgGOTfqZ6vY@P5orWylsSedhAmfXr3pd8k@dPLw9Goq01Lvz12SGd22frU3Vkrcwe1Z8g@I8ci3@vUNp3abBr3Ml8SjkbzT4pr0LwB "Python 3 – Try It Online")
[Answer]
# [Husk](https://github.com/barbuz/Husk), 7 bytes
```
EmLġ±Ẋ-
```
[Try it online!](https://tio.run/##yygtzv7/3zXX58jCQxsf7urS/f//f7ShjrGOqY6FjpmOiY4RmG0OZYNYlhB2LAA "Husk – Try It Online")
## How this works
```
EmLġ±Ẋ-  ~ Full program.
     Ẋ   ~ Map over pairs of adjacent elements.
      -  ~ With subtraction (this computes the deltas)
   ġ     ~ Group using equality predicate.
    ±    ~ Sign.
 mL      ~ Get the lengths.
E        ~ Are all equal?
```
Some cute alternatives:
```
εġLġ±Ẋ-
εüLġ±Ẋ-
```
[Answer]
# [Python 2](https://docs.python.org/2/), 96 bytes
```
import re
def f(x):exec"x=map(cmp,x[1:],x[:-1]);"*2;re.match('.([^1]*)(-?1, \\1)*9',`x+[9]`)<0<_
```
[Try it online!](https://tio.run/##XY1NU4MwEIbv/IodLk1o2hH6AYQ6nvToyRuNlsHFMiOQWdOZ9NdjWiyil0z23WffR5/NsWujvq8b3ZEBQu8dK6iY5RItlr69bwrNykYLm4dSuVcuQsUzP4gywmVTmPLIZkuWv4Yq4GzxEArY70MepDNxsPM8VQe@u9u99VVHUEPdAhXtB7KYSw/A0FnCxQN@xepWnwzjrjsDTXVr4IVO6Ci0JWoDz0WDj0QdyZ/1U/H5hV6fO@VKwEZAImArYC0guiXxJBnGdEyU93s5ciP0v8vRw2@axteD1TXZOmJcJ7emof7iSv743LCemB2fqm8 "Python 2 – Try It Online") Output via exit code: crash (1) is falsey, clean exit (0) is truthy.
### [Python 2](https://docs.python.org/2/), 106 bytes
```
def f(x):d=map(cmp,x[1:],x[:-1]);l=len(d);s=(d+[0])[0];k=(d+[-s]).index(-s);print((k*[s]+k*[-s])*l)[:l]==d
```
[Try it online!](https://tio.run/##XY3BDoIwEETvfsWG0y4WI6CCNP2SpgdDSyRibQQT/HqsEBE9dNOZfTvjnt35ZpNh0KaCCnsqtLieHJZXx3oZF8rPIooV8UY0xqIm3grUa7lV5B@/jCJqFW1qq02PUUvc3WvbIV5C2aq1n@912JAsGiWEHkxvSggqrK17dEjEAwghWw0yZpAy2DPIGRwY7BgkHydbOJM8zo5afS9nbob@szw9/ZZuNh6ko3PwxLzOP0lT/Lsr/@nzYrdo9vxRvQA "Python 2 – Try It Online")
[Answer]
# [Desmos](https://desmos.com/calculator), 82 bytes
```
f(l)=0^{mod(k/k[1],1).total}
L=D(D(l))
k=[1...L.length][LL=1]
D(l)=sign(l[2...]-l)
```
[Try It On Desmos!](https://www.desmos.com/calculator/9jddrzflvt)
[Try It On Desmos! - Prettified](https://www.desmos.com/calculator/cgoifst858)
### Explanation
`D(l)=sign(l[2...]-l)`: Takes the consecutive differences of the input list `l`, and takes the `sign` of the resulting differences.
`L=D(D(l))`: Applies the function `D` described above 2 times on `l`. The first difference will output a list (which I will denote as `A`) that, for each value of the original list `l[i]` for some `i` in the range `[1,l.length-1]`, does the following:
* If `l[i]<l[i+1]`, `A[i]` will be 1. In other words, if `l` increases from `l[i]` to the next element, then it is denoted in the new list as 1.
* If `l[i]>l[i+1]`, `A[i]` will be -1. In other words, if `l` decreases from `l[i]` to the next element, then it is denoted in the new list as -1.
Note that we don't have to consider the case where `l[i]=l[i+1]`, because that is guaranteed not to happen as per the specs:
> 
> * No adjacent elements will be equal
> 
> 
> 
The second difference outputs a list (denoted as `B` below) that does the following for each value in `A`, `A[i]`, for some `i` in the range `[1,A.length-1]` (remember that the first difference is denoted as `A`):
* If `A[i]=A[i+1]`, then `B[i]` will be 0. In terms of `l`, what this checks for is if `l[i]`, `l[i+1]`, and `l[i+2]` are all either increasing or decreasing.
* If `A[i]<A[i+1]`, then `B[i]` will be 1. In terms of `l`, what this checks for is if it decreases from `l[i]` to `l[i+1]`, but increases from `l[i+1]` to `l[i+2]`. In other words, this will check for transitions from a decreasing run to an increasing run.
* Similarly, if `A[i]>A[i+1]`, then `B[i]` will be -1. In terms of `l`, what this checks for is if it increases from `l[i]` to `l[i+1]`, but decreases from `l[i+1]` to `l[i+2]`. In other words, this will check for transitions from an increasing run to a decreasing run.
`k=[1...L.length][LL=1]`: Filters the range `[1...L.length]` based on whether `L*L` is 1. This essentially obtains a list of indices at which `L` is either 1 or -1, and removes the indices where it is 0. What this achieves is that it will find the indices of the "turning points".
`f(l)=0^{mod(k/k[1],1).total}`: Divides each element of `k` by the first element `k[1]`, and then takes the fractional part of the resulting quotients.
If the "turning points" are spaced out evenly, then this will result in a list of all 0's. Otherwise, at least one element will be a decimal number.
The `total` of this list is 0 only if the list only contains 0's, and nothing else. Otherwise, the `total` will be some number greater than 0. In other words, the `total` is 0 only if the elements are spaced out equally.
The last part is that, `0^0` is 1, will `0^n` for some positive number `n` is 0. We can take advantage of this by using the `total` we obtained, and raising 0 to the power of the `total`. Recall that if the "turning points" are all spaced out evenly, then the `total` will be 0. This will cause `0^{mod(k/k[1],1).total}` to be 1. Otherwise, if they aren't spaced out equally, the `total` is greater than 0, so `0^{mod(k/k[1],1).total}` will be 0.
[Answer]
# JavaScript (ES6), 81 bytes
This seems too long. I'm probably missing something here... Returns either `true` or `undefined`.
```
f=(a,p=1)=>a.every((n,i)=>!i|!(1/(y=a[i+1]))|!(i%p)^y>n^a[i-1]>n)||a[p]&&f(a,p+1)
```
Looks for a period ***0 < p < a.length*** such that all direction changes occur every ***p*** elements.
### Test cases
```
f=(a,p=1)=>a.every((n,i)=>!i|!(1/(y=a[i+1]))|!(i%p)^y>n^a[i-1]>n)||a[p]&&f(a,p+1)
console.log(f([1, 3, 5, 8, 6, 4, 2, 3, 5, 7, 6, 4, 2, 5, 7, 9, 6, 4, 2])) // -> True
console.log(f([1, 3, 5, 7, 6, 4, 5, 7, 9, 8, 6, 4, 2, 3, 5])) // -> False
console.log(f([2, 3, 6, 4, 2, 3, 7, 5, 3, 4, 6])) // -> True
console.log(f([3, 6, 4, 8, 5, 7, 3, 5, 2])) // -> True
console.log(f([8])) // -> True
console.log(f([1, 3, 5, 7])) // -> True
console.log(f([4, 5, 7, 6, 8, 9])) // -> False
console.log(f([15, 14, 17, 16, 19, 18])) // -> True
console.log(f([19, 15, 14, 17, 18, 17, 16, 19, 20])) // -> True
```
[Answer]
# [Haskell](https://www.haskell.org/), ~~79~~ ~~78~~ 77 bytes
```
import Data.List
g s|h:t<-(1<$)<$>group(zipWith(<)s$tail s)=all(==h)t
g _=1<3
```
[Try it online!](https://tio.run/##dY9NC4JAEIbv/opBPLiwBab5EbudOnrr0CEkFgpdWj9wx0v03y0VRaWO8/A@78xkQj8fSrWtzKuyRjgJFNtYajRS0O/sgGxjO8wizDqmddlU9ktWF4mZzYi2UEgFmnChlM15Rjrpxh3mtrmQBXC4lwZUtSwQLEjh6lBwKewphBR8Ch6F3UiCGRnGaCLJomRQ5nrQK25P/GV4SoZj7bBu1Rkmv@8MOt7gGeu4MM0/mXHFdPb6u2W5N7O@yShpPw "Haskell – Try It Online")
Given a list `s`, `zipWith(<)s$tail s`tests for each element whether it is smaller than its successor, e.g. `s=[2,3,6,4,2,3,7,5,3]` yields `[True,True,False,False,True,True,False,False]`. Then `group` runs of the same elements together: `[[True,True],[False,False],[True,True],[False,False]]`. To check whether all those lists have the same length, replace their elements with `1` ([see this tip](https://codegolf.stackexchange.com/a/146634/56433)) yielding `[[1,1],[1,1],[1,1],[1,1]]` and check if all elements in the tail `t` of this list equal the head `h`: `all(==h)t`.
This approach does not work for singleton lists, but because those are always true, we can handle them in their own case: `g[_]=1<3`.
[Answer]
# [R](https://www.r-project.org/), 57 bytes
```
function(x){d=diff
sum(rle(d(which(!!d(d(x)>0))))$v^0)<2}
```
[Try it online!](https://tio.run/##K/qfZvs/rTQvuSQzP0@jQrM6xTYlMy2Nq7g0V6MoJ1UjRaM8IzM5Q0NRMQXIrtC0M9AEApWyOANNG6Pa/8mJJRppGskahjoKxjoKpjoK5joKZjoKJjC2pY6CBUzECKIGqP0/AA "R – Try It Online")
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 15 bytes
```
ä- mg ò¦ mÊä¥ e
```
[Try it online!](https://tio.run/##y0osKPn///ASXYXcdIXDmw4tU8g93HV4yaGlCqn//0cb6igY6yiY6ihY6CiY6SiY6CgYwUTMkUQgXEu4SCwA "Japt – Try It Online")
## Explanation
```
ä- mg ò¦ mÊä¥ e                                                  [0,3,7,5,2,3,6]
ä-                // Difference between neighboring elements     [-3,-4,2,3,-1,-3]
   mg             // Get the sign of each element                [-1,-1,1,1,-1,-1]
      ò¦          // Partition between different elements        [[-1,-1],[1,1],[-1,-1]]
         mÊ       // Get the length of each element              [2,2,2]
           ä¥     // Check for uniqueness                        [true,true]
              e   // Return true if all elements are truthy      true
```
[Answer]
# Haskell (Lambdabot), 59 bytes
```
g(map(1<$).group.ap(zipWith(<))tail->h:t)=all(==h)t;g _=1<3
```
Based on @Laikoni's answer
[Answer]
## Clojure, ~~70~~ 63 bytes
```
#(<(count(set(map count(partition-by pos?(map -(rest %)%)))))2)
```
Returns true or false. The original answer was a bit silly.
[Answer]
# [Java (OpenJDK 8)](http://openjdk.java.net/), ~~437~~ ~~302~~ ~~256~~ 188 bytes
```
a->{int i=0,g=0,x=0,l=0;String d="";for(;i<~-a.length;d+=a[0].compare(a[i+1],a[i++])+1);for(String s:d.split("(?<=(.))(?!\\1)"))if(g++<1)x=s.length();else if(s.length()!=x)l++;return l<1;}
```
[Try it online!](https://tio.run/##TZBNT8MgGIDP7le86wksI6vfSrslHkw8eNqx6wFbVpkUCKVzyzL/esXZqSRvCM/7FZ413/CJsUKvq/deNtY4D@vAaOeloqtOl14aTc/ZyHavSpZQKt628MKlhv3orPXcB/g01KXP2otauLwg8GiMElzPwAonTRWqMuj5ZLaX2oPMpqQOsQ2hsilbeCd1DVUWRWxlHGIy/ZxwqoSu/Rur4ozn04KWprHcCcRzGScF@b7iAscJPvYMM9qHirZWSY8iNE8zRDFG8/FymeAIY7lCdRynCd5m7TAdYSZUKyCk/tA422IVx8wJ3zkNKk3YoWeDguHTGyMraIKIYXNeAMdBCgxnsWu9aKjpPLUh79FJBOXWqh3S4gN@fe0TApcErgncEbghcEXg4kRu/5Gf5/0vOWDMjhsPo0P/BQ "Java (OpenJDK 8) – Try It Online")
[Answer]
# [Java (OpenJDK 8)](http://openjdk.java.net/), 135 bytes
```
a->{Integer i=0,c,d=0,p=0,r=0;for(;++i<a.length;)d+=(i<2|(c=i.signum(a[i-1]-a[i]))<0?d<0:d>0)?c:p==0|p==-d?c-(p=d):1-(r=1);return r<1;}
```
[Try it online!](https://tio.run/##bVLBbuIwEL3zFaNKSPbiRDFQSpMYtMc9rLRSj4iDGztZs@BEtlOpovl21kkgZLc9jMd@8@bNWDMH/saDspL6IP5c1KkqjYODx8LaqWP4LZlU9etRZZAdubXwkysN5wnAFbWOO@/eSiXg5GPoxRmli90euCks7qgw0strnTlV6vCXkUJl3MlUabfbbyAHduHB5vxDO1lIA4pFJCPCn5U3w6IkLw1KZjOV8vAodeF@J1jMGFLp/ANlTIVWFbo@Ib5TAd0H3u0xTqOtSKNYbCK8zeKKsejDH4HYZgGqmMAxDZBhFCdGutpoMClNmkvSdd015n/ipHUW2PUvAGdKYEHgkcCawIrAksD8hjyNkP75PCAN@SQw0Afu/5L3pB4YB5@6vEWHrO7EgbW@6fbFRg2sv@rlji1HzXmR53/YPkIjb75Z2t4XHad11Pv54hpqseUosaV6XepV6erGGcXnI/zxmn8r3PQDaRegG0o3krgfDB7m8vJunTyFZe3Cyi@hy9HD1MYwfZ3qBwLfjeHvNnRlv6GoTcYE8rC99C/cl2kmrTWXvw "Java (OpenJDK 8) – Try It Online")
# Explanations
```
a->{                    // int array
 Integer i=0,c,d=0,p=0,r=0;
                        // variable definitions, use Integer to abuse static calls
 for(;++i<a.length;)    // Loop from 1 till length - 1
  d+=                   // Change d
   (i<2                 // First iteration?
     |(c=i.signum(a[i-1]-a[i]))<0?d<0:d>0
   )                    // Or do c and d have the same sign?
    ?c                  // then increase the magnitude of d.
    :p==0|p==-d         // else we're in a u-turn. Is it the first? Or is the magnitude the same as previously?
     ?c-(p=d)           // assign the new magnitude with sign to p and reset d to -1 (if was positive) or 1 (if was negative)
     :1-(r=1);          // else just do r=1 (technically: "add 1-1=0 to d" as well)
 return r<1;            // return whether there were wrong amplitudes.
}
```
[Answer]
# [Python 2](https://docs.python.org/2/), ~~110~~ 99 bytes
*-11 bytes thanks to @Lynn*
```
d=input()
exec"d=map(cmp,d[:-1],d[1:]);"*2
x=[i+1for i,e in enumerate(d)if e]
for i in x:i%x[0]>0<q
```
[Try it online!](https://tio.run/##XY5BT4QwEIXv/RUTEhPQmlBgWUDxpkdP3ggHhNls4wK1lsj@emzLwrIemum87828EWd17LtgqvsGc8dxpibnnRiU6xEcsXaavK2EW7eCNkX2yEpdWFZ6T859QMa84A/s0EvgFIF3gN3QoqwUuo3HD4AlsdCgMeN3Y@GXL/7z96RzyO@RnxA@5IAZAVDybAqACQVzjO2E5J2yJmJQjULBe9Xiq5S9zDaWt@r0c/XM5FNi9TUVjEJIYUchoRBTiCgEi7LfKHObrkpJrpOrbzX936Xd82@r7u1AaJVYO1acLJvm9SYrucnTTbRJ1v505lpivn76BGb@oYWmMF2D8IKMFpkJ49GbmN7D4gUaEGyE3WUiLf8A "Python 2 – Try It Online")
[Answer]
# [Ruby](https://www.ruby-lang.org/), 57 bytes
```
->a{!a.each_cons(2).chunk{|x,y|x>y}.uniq{|*,x|x.size}[1]}
```
[Try it online!](https://tio.run/##fZHdCoJAEIXvfYqJICymBc1KL/SyJ@hOJDYxkmqzbEFTn91sxWW1n73bwzkfZ2bufJ/XB@bWc48WI0oiGh534ZWlujkl4ZGzU1FmmJeZl1eEs/hWlDPMyoyk8TOqfCOo6pgl/AEu@BqAbyAsEJYINsIKwUIwO2WtKO3XkUqAMIa5B9s7j3oYGZKJIbiJqk9gNvScCk7rUf1rgVoIZTXIfnC6OpJhd0Xadu/efaf9B/lrxC@RntNSNtEUcHp@Zd5A05pLpCAOQi400ScHNq1f "Ruby – Try It Online")
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 9 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
Outputs `false` for truthy and `true` for falsey.
```
äÎòÎmÊäÎd
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=5M7yzm3K5M5k&footer=IVU&input=WzAgMyA3IDUgMiAzIDZd) (footer negates the output) or [run all test cases](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=5M7yzm3K5M5k&footer=IVU&input=WwpbMCAzIDcgNSAyIDMgNl0gICAgICAgICAgICAgICAgICAgICAgICAgICAgIC0%2bIHRydWUKWzEgNCA2IDggNSAzIDUgNyA5XSAgICAgICAgICAgICAgICAgICAgICAgICAtPiBmYWxzZQpbMSAzIDUgOCA2IDQgMiAzIDUgNyA2IDQgMiA1IDcgOSA2IDQgMl0gICAgIC0%2bIHRydWUKWzEgMyA1IDcgNiA0IDUgNyA5IDggNiA0IDIgMyA1XSAgICAgICAgICAgICAtPiBmYWxzZQpbMiAzIDYgNCAyIDMgNyA1IDMgNCA2XSAgICAgICAgICAgICAgICAgICAgIC0%2bIHRydWUKWzMgNiA0IDggNSA3IDMgNSAyXSAgICAgICAgICAgICAgICAgICAgICAgICAtPiB0cnVlCls4XSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLT4gdHJ1ZQpbMSAzIDUgN10gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC0%2bIHRydWUKWzQgNSA3IDYgOCA5XSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAtPiBmYWxzZQpbNiA0IDIgMyA1IDQgMl0gICAgICAgICAgICAgICAgICAgICAgICAgICAgIC0%2bIHRydWUKWzggNSAzIDIgNCA2IDUgMyAyIDUgN10gICAgICAgICAgICAgICAgICAgICAtPiBmYWxzZQpbMSA1IDEwIDE5IDE1IDEzIDggMTMgMTggMjMgMTkgMTggMTRdICAgICAgIC0%2bIHRydWUKWzE1IDE0IDE3IDE2IDE5IDE4XSAgICAgICAgICAgICAgICAgICAgICAgICAtPiB0cnVlClsxMiAxNiAxOSAxNSAxOCAxOV0gICAgICAgICAgICAgICAgICAgICAgICAgLT4gZmFsc2UKXS1tUg)
```
äÎòÎmÊäÎd     :Implicit input of array                                    > [0,3,7,5,2,3,6]
ä             :Consecutive pairs                                          > [[0,3],[3,7],[7,5],[5,2],[2,3],[3,6]]
 Î            :  Reduced by the sign of their differences (1 or -1)       > [-1,-1,1,1,-1,-1]
  ò           :Partition between elements that return true (not zero)
   Î          :  Get the sign of their difference                         > [[-1,-1],[1,1],[-1,-1]]
    m         :Map
     Ê        :  Length                                                   > [2,2,2]
      ä       :Consecutive pairs                                          > [[2,2],[2,2]]
       Î      :  Reduced by the sign of their differences                 > [0,0]
        d     :Any truthy?                                                > false
```
[Answer]
# [Husk](https://github.com/barbuz/Husk), 7 bytes
```
Λ≡gẊo±-
```
[Try it online!](https://tio.run/##yygtzv7//9zsR50L0x/u6so/tFH3////0QY6xjrmOqY6RkDaLBYA "Husk – Try It Online")
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), 5 bytes
```
¯±Ġȧ≈
```
[Try it Online!](https://vyxal.pythonanywhere.com/#WyJQIiwixpsiLCLCr8KxxKDIp+KJiCIsIjtaxptgID0+IGBqO+KBiyIsIltbMSwgMywgNSwgOCwgNiwgNCwgMiwgMywgNSwgNywgNiwgNCwgMiwgNSwgNywgOSwgNiwgNCwgMl0sIFsxLCAzLCA1LCA3LCA2LCA0LCA1LCA3LCA5LCA4LCA2LCA0LCAyLCAzLCA1XSwgWzIsIDMsIDYsIDQsIDIsIDMsIDcsIDUsIDMsIDQsIDZdLCBbMywgNiwgNCwgOCwgNSwgNywgMywgNSwgMl0sIFs4XSwgWzEsIDMsIDUsIDddLCBbNCwgNSwgNywgNiwgOCwgOV0sIFsxLCA1LCAxMCwgMTksIDE1LCAxMywgOCwgMTMsIDE4LCAyMywgMTksIDE4LCAxNF0sIFsxNSwgMTQsIDE3LCAxNiwgMTksIDE4XSwgWzEyLCAxNiwgMTksIDE1LCAxOCwgMTldXSJd)
Port of Jelly answer.
## How?
```
¯±Ġȧ≈
¯     # Get the deltas (consecutive differences) of input
 ±    # Get the sign (implicit vectorization)
  Ġ   # Group consecutive identical items
   ȧ  # Absolute value (implicit double-vectorization)
    ≈ # All equal?
```
[Answer]
# [Factor](https://factorcode.org/), 49 bytes
```
[ [ trends check-lengths t ] [ tuple? ] recover ]
```
[Try it online!](https://tio.run/##dZHBTsMwEETv/YrhAxqJNrQBJHor4sIFOFU9RGZpLZy1sTdIqOq3BzsOUCK4Pc3Ojkfrl1qJ9d3Tw9397RWCM1pE865oLFuxrBWUbZw25AvxRIXak3olH1WOvrYWbTkgKkwGzpPIh/OaBYHeWmJFAdeTw@SAc8xxgQoLlJj1vBw40eXAR5xheoNH39L3TvZl1@n@4F3XJiRzEr@GyzieR16MArOj6sNSxPjB6p8Cv9VyKFXFQqMSP@3KP8JTqVlfK9NJdA44dhtsEA/NzwH9qaeGeCf7AME2jVpnaBXRk7Lv8R@2XVM7FFCGat99Ag "Factor – Try It Online")
There is a lot to unpack here. First, Factor (nearly!) has the perfect word for this problem, `trends`, which splits a sequence into its rising, falling, and stable parts. This question guarantees no two adjacent elements will be equal, so we don't need to worry about receiving any stable trends in the result.
The problem is, for some unfathomable reason, if the sequence has only one trend, `trends` returns a single trend object instead of a sequence with a single trend object in it. Thus when we attempt to see if the lengths of the trends are all equal, we'll get an error that `length` can't be applied to a non-sequence if there is only a single trend.
Next, instead of saying something like `[ length ] map all-eq?`, Factor has a word in its (exposed) compiler named `check-lengths` that throws an error if the lengths of a sequence are not all equal. So `check-lengths` is capable of failing in two different ways: either it'll end up calling `length` on a non-sequence, or it'll throw an error if the lengths of its input are not all the same.
Enter `recover`, one of Factor's exception handling words. It calls the first quotation (which will simply return `t` if no errors are encountered) and calls the second quotation with the error on top of the stack if the first quotation encounters an error. Inside this quotation, all we need to do is check whether the error is a tuple or not, because calling `length` on a non-sequence produces an actual error tuple while `check-lengths` throws a simple string error if the lengths are unequal.
]