Skip to content

Instantly share code, notes, and snippets.

@BenMaydan
Last active August 15, 2019 19:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BenMaydan/571a0732e7fbb5fa101027898fa24a24 to your computer and use it in GitHub Desktop.
Save BenMaydan/571a0732e7fbb5fa101027898fa24a24 to your computer and use it in GitHub Desktop.
A function to check if a list (or generator/tuple/set/dict keys) is strictly increasing by some arbitrary number
def increasing(values, amount):
"""
Checks if every value in a list of values increases by some arbitrary amount
:param values: The list of values
:param amount: The amount the values in the list should increase by
:return: True or False
"""
for current, future in zip(values, values[1:]):
if current != future - amount:
return False
return True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment