You are viewing a single comment's thread. Return to all comments →
My shortest solution…
from itertools import * print(*list((len(list(g)), int(k)) for k, g in groupby(input())))
A solution without groupby()…
groupby()
o = p = [] for c in map(int, input()): if c == p: n += 1 continue o += [(n, p)] if p != [] else [] p = c n = 1 print(*(o + [(n, p)]))
Seems like cookies are disabled on this browser, please enable them to open this website
Compress the String!
You are viewing a single comment's thread. Return to all comments →
My shortest solution…
A solution without
groupby()
…