Last active
August 15, 2019 19:42
-
-
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
This file contains 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 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