Forum Discussion
sirwazzles
Feb 18, 2023Copper Contributor
Most # of repeats/duplicates back to back
If I have a column of cells, each cell having a 0 or a 1, how do I count the most number of repeats “back to back”? I want to know the most # of times the number 1 occurs back to back.
ex.
0,1,0,1,0,0,1,1,0,1,1,1,1,0,0
The above should return the answer as “4” because the number 1 repeats 4 times back to back.
- sirwazzlesCopper Contributor
SergeiBaklan Thanks for the response! I was able to use this code.
sirwazzles , you are welcome
As variant
=INDEX( REDUCE( {0,0}, A1:A15, LAMBDA(a,v, IF( v = 0, a * {0,1}, IF(INDEX(a, , 1) < INDEX(a, , 2), a + {1,0}, a + {1,1}) ) ) ), , 2 )