Skip to content

Instantly share code, notes, and snippets.

@PengFoo
Created November 1, 2015 17:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PengFoo/51c0428fb67447abaf6a to your computer and use it in GitHub Desktop.
Save PengFoo/51c0428fb67447abaf6a to your computer and use it in GitHub Desktop.
def find(s):
res,start,cur = [],1,s[0]
for index,i in enumerate(s):
if i != cur:
res.append((start,index))
start = index + 1
cur = i
res.append((start,len(s)))
return res
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment