In a strictly increasing ordered sequence of integers (such as 5, 8, 12, 20 for example) each element is strictly larger than the previous one: for all , that is, .
A -ordered sequence is a sequence where for all . Thus, a strictly increasing sequence is 0-ordered, and a sequence that is increasing but maybe not strictly (like -3, -1 -1, 4, 4, 7 for example) is 1-ordered.
Larger values of represent bounded disorder: bounds how smaller than its predecessor each element can be.
Write a function
that receives a nonnegative integer
and a list
of integers and checks whether
is
-ordered,
that is, returns True if
is
-ordered,
and False otherwise.
Only the function will be evaluated. If your submission includes a
main program (e.g. with testmod), it must be either commented out or
inside a condition "if __name__ == ’__main__’"
>>> disorder_test(0, [-2, -1, 0, 3, 7, 15, 32]) True >>> disorder_test(1, [-2, -2, -1, 0, 3, 7, 15, 15, 32]) True >>> disorder_test(0, [-2, -2, -1, 0, 3, 7, 15, 15, 31, 31]) False >>> disorder_test(1, [-2, -2, -1, 0, 3, 7, 15, 15, 31, 31]) True >>> disorder_test(0, [-2, -1, 0, 3, 2, 2]) False >>> disorder_test(1, [-2, -1, 0, 3, 2, 2]) False >>> disorder_test(2, [-2, -1, 0, 3, 2, 2]) True