def edit_distance(s, t, maxdiff=-1):
    """
	Return the edit distance between the strings s and t.
	The edit distance is the sum of the numbers of insertions, deletions,
	and mismatches that is minimally necessary to transform one string
	into the other.

	If maxdiff is not -1, then a banded alignment is performed. In that case,
	the true edit distance is returned if and only if it is maxdiff or less.
	Otherwise, a value is returned that is guaranteed to be greater than
	maxdiff, but which is not necessarily the true edit distance.
	"""
    m = len(s)
    n = len(t)
    e = maxdiff
    if e != -1 and abs(m - n) > e:
        return abs(m - n)
    costs = list(range(m + 1))
    for j in range(1, n + 1):
        start = 1
        stop = m + 1
        if e != -1:
            stop = min(stop, j + e + 1)
            if j <= e:
                prev = costs[0]
                costs[0] += 1
                start = 1
            else:
                start = j - e
                prev = costs[start - 1]
        else:
            prev = costs[0]
            costs[0] += 1
        for i in range(start, stop):
            c = min(prev + int(s[i - 1] != t[j - 1]), costs[i] + 1, costs[i -
                1] + 1)
            prev = costs[i]
            costs[i] = c
    return costs[-1]
