Problem 2773. Find the distance between runs
Another question inspired by the answers forum:
A vector of monotonically increasing integers may contain several runs of consecutive numbers. Find out the distance between the end of runs of at least 4 consecutive numbers and the beginning of the next run of at least 4 consecutive numbers. E.g:
v = [1,2,5,6,7,8,9,20,21,22,30,31,32,33,34,35,40,41,42,43,44];
has three runs of at least 4 numbers, [5 6 7 8 9], [30,31,32,33,34,35] and [40,41,42,43,44]. So,
d = [30-9, 40-35] = [21 5]
Solution Stats
Problem Comments
-
1 Comment
Mattias
on 3 Jan 2015
Nice challenging problem! The fun thing is that all solutions look very different and are also very hard to understand
Solution Comments
Show commentsGroup

Indexing IV
- 15 Problems
- 28 Finishers
- Hard limit function
- How to reverse spdiags?
- Combine Data With Gaps
- Sum My Indices
- Longest Sequence of NaNs
- Find the same and successive values in a vector
- Pancake sorting - minimum flips.
- Elements with highest local average
- Neither minima nor maxima
- How to reverse spdiags?
- Find indices of diagonal elements
- Find Elements in Range
- Find the same and successive values in a vector
- Find the distance between runs
- Split array into pieces according to corresponding array
- How close to a hole
- Pancake sorting
- Pancake sorting - minimum flips.
- Combine Data With Gaps
- Sum My Indices
- Longest Sequence of NaNs
Problem Recent Solvers53
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!