Last active
December 26, 2015 00:09
-
-
Save janosgyerik/7062399 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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