Hello all, So you have to find the largest section of zeros in a vector and then find the length of those zeros and there starting position... For example:
x = [1 2 3 4 5 6 7 8 9 0 0 0 0 0 0 0 0 0 9 8 7 6 5 4 3 2 1]; %then the output is: LP = [9 10] %[Length Position]
%Or another example:
x = [1 0 3 49 3 2 232 3 0 0 0 0 0 0 8 290 0 0 0 12 323 34]; %then the output is: LP = [6 9]
%Or another example:
x = [1 1 0 0 0 0 0 0 0 1 1 1 1 1 1 0]; %then the output is: LP = [7 3];
Have Fun!
It's "their starting position" not "there starting position"...
no fancy function, no eccentric useage, and problem was swiftly solved. Excellent code!
GREAT!!! :-)
Would of never guessed it!
This actually has a minor bug -- it may fail on inputs containing negative numbers, e.g. x=[1 -1], however this is simply fixable by taking abs(x).
wonderful solution
it never gets tired to watch this kinda code.
7273 Solvers
13816 Solvers
202 Solvers
276 Solvers
Square Digits Number Chain Terminal Value (Inspired by Project Euler Problem 92)
146 Solvers