Skip to main content
deleted 4 characters in body
Source Link
Uriel
  • 13.2k
  • 4
  • 17
  • 45

Python, 7676 72 bytes

lambdaf=lambda s,k=1:sumlen(k*s)and(2**lenf([*g])-1s,s[0])forif s[0]*abs(k,g in)/k-1else groupbyk+f(ss[1:],2*k))
from itertools import*

Try it online!Try it online!

Python, 76 bytes

lambda s:sum(k*(2**len([*g])-1)for k,g in groupby(s))
from itertools import*

Try it online!

Python, 76 72 bytes

f=lambda s,k=1:len(s)and(f(s,s[0])if s[0]*abs(k)/k-1else k+f(s[1:],2*k))

Try it online!

Source Link
Uriel
  • 13.2k
  • 4
  • 17
  • 45

Python, 76 bytes

lambda s:sum(k*(2**len([*g])-1)for k,g in groupby(s))
from itertools import*

Try it online!