Hi,
I have a simple array with 1s and 0s. But I want to identify the frequency of continuous 1s in the array, so for example in the array below:
0,1,1,1,0,0,1,1,0,0,0,0,1,1,1,0,0,1,1,1,0,0,
The program should be able to look through the array and churn out variables along the lines of:
One_1_in_a_Row = 0
Two_1_in_a_Row = 1
Three_1_in_a_Row = 3
(I have used crude variable names just to explain the scenario, the values correspond to the number of times the particular length of 1s in a row were identified)
I am thinking of writing something which scans through the data, when it finds a 1 it then looks at the next position and if it is also a 1 it will increment a counter, it keeps incrementing the counter until it finds a 0 and it stops counting, it then identifies the number in the counter ie if the counter went up to 6 then it will increment the variable Six_1_in_a_Row , then it will carry on in this manner until it has scanned the entire array.
Is this a decent method for what I am looking to do?
Thanks
Bookmarks