Exemple #1
0
def computeCommonPrefixLengthOfPair(s1, s2):
    result = 0
    for i in range(min(len(s1), len(s2))):
        # s1[i] ==> IE6 FAIL, IIRC
        if s1.substr(i, 1) == s2.substr(i, 1):
            result += 1
        else:
            break
    return result
Exemple #2
0
def computeCommonSuffixLengthOfPair(s1, s2):
    result = 0
    s1_len = len(s1)
    s2_len = len(s2)
    for i in range(min(s1_len, s2_len)):
        # s1[i] ==> IE6 FAIL IIRC
        if s1.substr(s1_len - 1 - i, 1) == s2.substr(s2_len - 1 - i, 1):
            result += 1
        else:
            break
    return result