Length of Longest Ascending Factor X86404


Statement
 

pdf   zip

html

Write a function asc_stair that receives as argument a sequence of non-negative integers, and returns the length of the longest “ascending staircase” or subsequence of consecutive integers where each is strictly bigger than the previous one (technically, the length of the longest ascending factor).

Input is received as argument of the function. It is a list of integer values, all positive or zero.

The result returned by the function must be an integer k such that the longest ascending sequences of consecutive integers in the input are of length k.

Sample session
>>> asc_stair([ 1, 2, 3, 3, 1, 3, 5, 7, 2, 4, 6, 8, 8, 9, 10 ])
4
>>> asc_stair([ ])
0
>>> asc_stair([ 234 ])
1
>>> asc_stair([ 44, 43, 42, 41, 40 ])
1
>>> asc_stair([ 44, 43, 42, 50, 41, 40 ])
2
>>> asc_stair([ 44, 43, 42, 41, 40, 50 ])
2
>>> asc_stair([ 40, 44, 43, 42, 41, 40 ])
2
>>>
Information
Author
ProAl
Language
English
Official solutions
Python
User solutions
Python