Skip to content

Instantly share code, notes, and snippets.

@refi64
Created November 10, 2016 01:45
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 refi64/e656ba6088632c37b95bc5b900ce7f8c to your computer and use it in GitHub Desktop.
Save refi64/e656ba6088632c37b95bc5b900ce7f8c to your computer and use it in GitHub Desktop.
import re
def myfunc(s):
m = re.match(r'^(.+?)\1+$', s)
return len(s)/len(m.groups()[0])
print(myfunc('abccbaabccba'))
print(myfunc('abcabcabcabc'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment