Python 3, 91(削除) 91 (削除ここまで) 90 bytes
lambda x:''.join(l!="0"andl>"0"and l or f'{len([*g])}'for l,g in groupby(x))
from itertools import*
-1 byte thanks to The Thonnu
I use the itertools module's groupby function to group consecutively.
Python 3, 91 bytes
lambda x:''.join(l!="0"and l or f'{len([*g])}'for l,g in groupby(x))
from itertools import*
I use the itertools module's groupby function to group consecutively.
Python 3, (削除) 91 (削除ここまで) 90 bytes
lambda x:''.join(l>"0"and l or f'{len([*g])}'for l,g in groupby(x))
from itertools import*
-1 byte thanks to The Thonnu
I use the itertools module's groupby function to group consecutively.
Python 3, 91 bytes
lambda x:''.join(l!="0"and l or f'{len([*g])}'for l,g in groupby(x))
from itertools import*
I use the itertools module's groupby function to group consecutively.