33
1
...but hey, no need to be strict.
Given a non-empty array of strictly positive integers, determine if it is:
- Monotone strictly decreasing. This means that each entry is strictly less than the previous one.
- Monotone non-increasing, but not strictly decreasing. This means that each entry is less than or equal to the preceding, and the array does not fall in the above category.
- None of the above.
Note the following corner cases:
- An array with a single number is monotone strictly decreasing (vacuously so).
- An array with the same number repeated is monotone non-increasing, but not strictly decreasing.
Rules
You may provide a program or a function
Input can be taken in any reasonable format: array, list, string with numbers separated by spaces, ...
You can choose any three consistent outputs for the three categories respectively. For example, outputs can be numbers 0
, 1
, 2
; or strings 1 1
, 1 0
, empty string.
Shortest code in bytes wins
Test cases
Monotone strictly decreasing:
7 5 4 3 1
42 41
5
Monotone non-increasing, but not strictly decreasing:
27 19 19 10 3
6 4 2 2 2
9 9 9 9
None of the above:
1 2 3 2
10 9 8 7 12
4 6 4 4 2
Does writing a variadic function (where the input values aren't wrapped in any kind of data type at all but are all passed straight to the function as arguments) fall under "any reasonable format"? – Martin Ender – 2016-11-25T07:54:43.437
@Martin Yes, it does! – Luis Mendo – 2016-11-25T08:50:44.330