Implement a function, called increasing_or_decreasing(ns) where ns is a list of integers.
The function should return a value from the following enum:
from enum import Enum
class Monotonicity(Enum):
INCREASING = 1
DECREASING = 2
NONE = 3- It should return
Monotonicity.INCREASING, if for every two elements,aandb, that are next to each other, we havea < b - It should return
Monotonicity.DECREASING, if for every two elements,aandb, that are next to each other, we havea > b - It should return
Monotonicity.NONEif it's neither increasing nor decrasing.
Signature
def increasing_or_decreasing(ns):
passExamples
increasing_or_decreasing([1, 2, 3, 4, 5]) == Monotonicity.INCREASING
increasing_or_decreasing([5, 6, -10]) == Monotonicity.NONE
increasing_or_decreasing([1, 1, 1, 1]) == Monotonicity.NONE
increasing_or_decreasing([9, 8, 7, 6]) == Monotonicity.DECREASING
increasing_or_decreasing([]) == Monotonicity.NONE
increasing_or_decreasing([1]) == Monotonicity.NONE
increasing_or_decreasing([1, 100]) == Monotonicity.INCREASING
increasing_or_decreasing([1, 100, 100]) == Monotonicity.NONE
increasing_or_decreasing([100, 1]) == Monotonicity.DECREASING
increasing_or_decreasing([100, 1, 1]) == Monotonicity.NONE
increasing_or_decreasing([100, 1, 2]) == Monotonicity.NONE