# Is there a straight forward simple mathematical function that can detect piecewise constant lengths?

Given an integer monotone sequence that only changes by 1, is there a "simple" mathematical function that returns the lengths of the constant subsequences?

E.g., [1,1,1,2,2,3,3,3,3,3,...] -> [3,2,5,...]

By "simple" I sort of mean something that can be used analytically. Obviously it is not difficult to write a function in code that returns the lengths but I'm wondering if there is something that potentially can be used algebraically. Not sure how to express exactly what I mean but something that is more "standard" and open to directly mathematical analysis than some procedure in code.

• I don't see how to get rid of min and argmin or cardinality but this is interesting (+1) although I would think that the answer is no. It is not bad news since tropical geometry (I believe) uses max and mins to replace some arithmetic operations Commented Jun 23, 2023 at 22:40
• The answer depends on what is "straight forward" and "simple" for you. You can obviously write this function in the form of a recursive function and then analyze it by applying recursive function theory. For people that work in this field this may seem "straight forward" and "simple", and for others, it may seem difficult. So the best answer is: It depends. Commented Jun 24, 2023 at 17:32