(a, b)
return c[n, m]
This function was giving by Magnus Lie Hetland. It calculates the gap
    (mathematical distance) between two strings with the cost of word's
    translation inside the string.
This function was giving by Magnus Lie Hetland. It calculates the gap
    (mathematical distance) between two strings with the cost of word's
    translation inside the string.
This function was giving by Magnus Lie Hetland . It calculates the gap ( mathematical distance ) between two strings with the cost of word s translation inside the string .
def get_distance(a, b):
    """
    This function was giving by Magnus Lie Hetland. It calculates the gap
    (mathematical distance) between two strings with the cost of word's
    translation inside the string.
    """
    # XXX Find URL to original code, check license
    c = {}
    n = len(a)
    m = len(b)
    for i in range(0, n+1):
        c[i, 0] = i
    for j in range(0, m+1):
        c[0, j] = j
    for i in range(1, n+1):
        for j in range(1, m+1):
            x = c[i-1, j] + 1
            y = c[i, j-1] + 1
            if a[i-1] == b[j-1]:
                z = c[i-1, j-1]
            else:
                z = c[i-1, j-1] + 1
            c[i, j] = min(x, y, z)
    return c[n, m]
def get_distance ( a , b ) : # XXX Find URL to original code, check license c = { } n = len ( a ) m = len ( b ) for i in range ( 0 , n + 1 ) : c [ i , 0 ] = i for j in range ( 0 , m + 1 ) : c [ 0 , j ] = j for i in range ( 1 , n + 1 ) : for j in range ( 1 , m + 1 ) : x = c [ i - 1 , j ] + 1 y = c [ i , j - 1 ] + 1 if a [ i - 1 ] == b [ j - 1 ] : z = c [ i - 1 , j - 1 ] else : z = c [ i - 1 , j - 1 ] + 1 c [ i , j ] = min ( x , y , z ) return c [ n , m ]