Created
November 14, 2023 01:17
-
-
Save GRAYgoose124/5c8d3bc97a22c273c13f66b56c3599fd to your computer and use it in GitHub Desktop.
Python is monotonic oneliner
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def is_monotonic(l): | |
return all((l[i] - l[i+1]) * (l[i+1] - l[i+2]) >= 0 for i in range(len(l)-2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment