Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

check if array is monotonic python

def strictly_increasing(L):
    return all(x<y for x, y in zip(L, L[1:]))

def strictly_decreasing(L):
    return all(x>y for x, y in zip(L, L[1:]))

def non_increasing(L):
    return all(x>=y for x, y in zip(L, L[1:]))

def non_decreasing(L):
    return all(x<=y for x, y in zip(L, L[1:]))

def monotonic(L):
    return non_increasing(L) or non_decreasing(L)
Comment

PREVIOUS NEXT
Code Example
Python :: sentence similarity spacy 
Python :: fibonacci series using recursion in python 
Python :: python print format 
Python :: numpy divide except 
Python :: python program to check if binary representation is a palindrome 
Python :: python equals override 
Python :: how to take multiple line inputs in python 
Python :: django admin 
Python :: python pandas table save 
Python :: python user input to tuple 
Python :: planets list 
Python :: making gifs via python 
Python :: get names of all file in a folder using python 
Python :: Generate 3 random integers between 100 and 999 which is divisible by 5 
Python :: python tkinter cursor types 
Python :: lagrange polynomial python code 
Python :: quick sort python 
Python :: pytorch load pt file 
Python :: how to make chrome extension in python 
Python :: Range python iterate by 2 
Python :: cli args python 
Python :: python datetime get date one week from today 
Python :: add two column values of a datframe into one 
Python :: tensorflow to numpy 
Python :: python math operators 
Python :: UnicodeDecodeError: ‘utf8’ codec can’t decode byte 
Python :: how to open a dataset in netcdf4 
Python :: -- python 
Python :: how to reset username and password in django admin 
Python :: numpy diff 
ADD CONTENT
Topic
Content
Source link
Name
9+7 =