Skip to content

Instantly share code, notes, and snippets.

@chuajiesheng
Last active January 5, 2017 08:30
Show Gist options
  • Save chuajiesheng/9774670d1b2787c051456ac11e828201 to your computer and use it in GitHub Desktop.
Save chuajiesheng/9774670d1b2787c051456ac11e828201 to your computer and use it in GitHub Desktop.
def parts(str, current, elements):
if len(str) < 1:
return elements + [current]
if current == '' or current.startswith(str[0]):
return parts(str[1:], current + str[0], elements)
return parts(str[1:], str[0], elements + [current])
''.join(list(map(lambda x: x[0] + str(len(x)), parts('aaabbcccddd', '', []))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment