Row 1 has a sequence of 1, then a sequence of 2 then a sequence of 1
identical values.
So it has 2 sequences of 1 and 1 sequence of 2
If you do that for each row and then find the totals for each sequence value
there are 5 sequences of 1
7 sequences of 2
No sequences of 3
1 sequence of 4
Hence
1:5
2:7 etc.
He would need to step through each row identifying sequences, accumulating
the counts of sequences in an array, and then suck them out of the array and
put them in the target cells.
I do not have the time to write this for him. Is it school homework? If so
perhaps I have given enough help?