Skip to content

Instantly share code, notes, and snippets.

@janosgyerik
Last active December 26, 2015 00:09
Show Gist options
  • Select an option

  • Save janosgyerik/7062399 to your computer and use it in GitHub Desktop.

Select an option

Save janosgyerik/7062399 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import sys
s1 = sys.argv[1]
s2 = sys.argv[2]
def longest(s1, s2):
def longest(i):
suffix = s2[i:]
if s1.startswith(suffix):
return suffix
else:
return longest(i + 1)
return longest(max(0, len(s2) - len(s1)))
print longest(s1, s2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment