I have a list that looks like this.
[6, 1, 1, 1, 5, 1, 7, 1, 7, 1, 7, 7, 7, 1, 7, 1, 1, 3, 1, 1, 1, 1]
There are some consecutive 1s in it.
After counting the number of consecutive 1s, I want to sum all the 1s and add 1 to each sum like this.
1,1,1,1 => 5
1,1,1 => 4
1,1 => 3
1 => 2
And then, I want to put them in each place where the consecutive 1 were.
[6, 4, 5, 2, 7, 2, 7, 2, 7, 7, 7, 2, 3, 5]
Finally, I want to change any numbers other than 1 to 1 without changing the bold text.
[1, 4, 1, 2, 1, 2, 1, 2, 1, 1, 1, 2, 1, 5]
How can I do this?
Any help will be greatly appreciated.