summaryrefslogtreecommitdiff
path: root/progs/a680.py
blob: 03f4da8876ffa371457a2c1c9d91963db2569089 (plain)
1
2
3
4
5
6
from itertools import groupby
def modified_encode(alist):
        def ctr_ele(el):
            if len(el)>1: return [len(el), el[0]]
            else: return el[0]
        return [ctr_ele(list(group)) for key, group in groupby(alist)]