Skip to content

Instantly share code, notes, and snippets.

@GRAYgoose124
Created November 14, 2023 01:17
Show Gist options
  • Save GRAYgoose124/5c8d3bc97a22c273c13f66b56c3599fd to your computer and use it in GitHub Desktop.
Save GRAYgoose124/5c8d3bc97a22c273c13f66b56c3599fd to your computer and use it in GitHub Desktop.
Python is monotonic oneliner
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