Make a list in particular Way

Suppose I have random list in which some numbers are same.. like in above 3 is repeating.. I want to create partition like above on right side. but I made it manually.. I want each consecutive-similar numbers should be in length and non consecutive & non- similar the others should be appear as 1.

to make desired combination or pattern of data

thank you

But, be careful, in a situation like this it may not answer your question.

we should use sort list for that

Maybe it’s better this way.

list.gh (9.4 KB)