Problem 44500. Find the starting index of a consecutive condition
Given a logical vector v, and a positive integer n, return the smallest index i that satisfies:
all( v(i : i+n-1) ) == true
For Example,
v = logical([0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0]); i = consecutiveFind(v, 4);
Then:
i = 6
If there is no sequence of n consecutive true, then i should be an empty array.
Solution Stats
Problem Comments
- 
		1 Comment
		Atsushi Ueno
    	on 16 Nov 2019
	
	
  	The test suite is not enough because it does not contain any case that the number of consecutive true bits is exactly same as n.
Solution Comments
Show commentsProblem Recent Solvers59
Suggested Problems
- 
         Make the vector [1 2 3 4 5 6 7 8 9 10] 51872 Solvers 
- 
         Cell Counting: How Many Draws? 2261 Solvers 
- 
         
         5608 Solvers 
- 
         
         484 Solvers 
- 
         Deleting an element in a matrix 480 Solvers 
More from this Author25
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!