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.