Jun-22-2020, 04:51 PM
Just brute force :-)
from itertools import groupby a = [1, 1, 2, 2, 1, 1, 1, 2, 1, 1, 1, 2, 2, 2, 2, 1, 2, 1, 1, 2, 2, 1, 1, 1] for item in set(a): print(f'{item}: {max(len([*streak]) for el, streak in groupby(a) if item == el)}') # will output something like that (sets are unordered): 1: 3 2: 4
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.