I am trying to return a boolean which only gives the longest "True" occurrence in the original boolean and replace shorter "True" chunks into "False". Example a=[True, True, False, True , True, True, False], i want to return [False, False, False, True, True, True, False].
i tried more_itertools and it seems to have some interesting functions but not sure how to exactly implement for my purpose.
a=[True, True, False, True , True, True, False]
pred = lambda x: x in {True}
p=list(mit.run_length.encode(a))
>>>
Results in: (True,2),(False,1),(True,3),(False,1)
So what i want to eventually automatically get is (False,3),(True,3),(False,1). any suggestions? Thank you for your help