Disorder Test

In a strictly increasing ordered sequence of integers x0,,xrx_0,\ldots,x_r (such as 5, 8, 12, 20 for example) each element is strictly larger than the previous one: xi>xi1x_i > x_{i-1} for all i>0i > 0, that is, xi1xi<0x_{i-1} - x_i < 0.

A kk-ordered sequence is a sequence where xi1xi<kx_{i-1}-x_i < k for all i>0i > 0. 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 kk represent bounded disorder: kk bounds how smaller than its predecessor each element can be.

Write a function disorder_test(k,ls)disorder\_test(k, ls) that receives a nonnegative integer kk and a list lsls of integers and checks whether lsls is kk-ordered, that is, returns True if lsls is kk-ordered, and False otherwise.

Observation

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__’"

Problem information

Author: ProAl

Generation: 2026-01-25T17:01:57.619Z

© Jutge.org, 2006–2026.
https://jutge.org