Count consecutive similar numbers

Hello everyone,

I am trying to solve a problem. I need to count the consecutive similar numbers in a branch. For example from the data tree branch {84;0} of the image attached, I need a new data tree with these two possibilities in branch {84;0}: 1) I do not indicate any number I am looking for and in branch {84;0} the new items are (in order) 5, 2, 10, 1; or 2) I indicate the how many consecutive number 1 there are in the branch and the new items in branch {84;0} are 5, 10.
Thank you in advance.
Francesco

Something like this?


Count Consecutive_re.gh (11.5 KB)

1 Like

Hello HS_Kim,

Thank you very much. Looking at the picture of the definition yes it makes the work. I do not understand where you ask to count the number 1 though, that in the first branch return 6 and 3. I will check the attached definition.

Best,
Francesco

I checked the attached definition and it works.
Thank you again HS_Kim.

Best,
Francesco

Check this as well

count.gh (8.3 KB)

Hello Seghier Khaled,

This also works fine. Thank you very much.

Best,
Francesco

Thank you also for this solution Seghier Khaled.

Best,
Francesco

1 Like