I would like to find the longest sequence of "1" (consecutive ones) in rows of a matrix; moreover, I would like to know the position of this sequence in the matrix .
Example:
Input :
M ={{1, 1, 0, 0, 1}, {1, 0, 0, 0, 1}, {0, 1, 0, 1, 0},
{0, 0, 0, 1, 0}, {0, 0, 1, 0, 0}, {0, 1, 1, 0, 0},
{1, 0, 1, 1, 1}}
Output expected
row : 7 Column: 3 to 5
Or a similar result with the same information.
(SequenceCases[#, {p : Repeated[1]} :> Length[{p}]])&/@m//Maxgives max value (see documentation for SequenceCases)) – user1066 Aug 03 '21 at 20:38