Ascending list

Ascending list

Tags: Data Structures Algorithms Sequences

Credit: Ilkka Kokkarinen

Difficulty: Easy

Type: Text

Category: Practice

Time Allowed: 15 s

Description:

Determine whether the sequence of items is strictly ascending so that each element is strictly larger (not just merely equal to) than the element that precedes it. Return True if the elements in the list of items are strictly ascending, and return False otherwise.

Note that the empty sequence is ascending, as is also every one-element sequence, so be careful to ensure that your function returns the correct answers in these seemingly insignificant edge cases of this problem. (If these sequences were not ascending, pray tell, what would be the two elements that violate the requirement and make that particular sequence not be ascending?)

In the same spirit, note how every possible universal claim made about the elements of an empty sequence is trivially true! For example, if items is the empty sequence, the two claims “All elements of items are odd” and “All elements of items are even” are both equally true, as is also the claim “All elements of items are colourless green ideas that sleep furiously”

Test Case Input Expected Output
1 [] True
2 [0] True
3 [2, 3] True
4 [4, 8, 15, 16, 23, 42] True
5 [5, 5] False
6 [-100, -50, 0, 50, 100, 150] True

Please register or login to submit solutions to challenges.