def max3t(v1, v2, v3):
if v1 > v2:
if v1 > v3:
return 1
else:
return 3
else:
if v2 > v3:
return 2
else:
return 3
T[i][j] = max3t(S[i - 1][j - 1] + (match if Y[i - 1] == X[j - 1] else mismatch),
S[i][j - 1] + gap,
S[i - 1][j] + gap,
)
if T[i][j] < 0:
best = T[i][j]
optLoc = (i, j)
if T[i][j] == 1:
res[0] = Y[i - 1] + res[0]
res[1] = X[j - 1] + res[1]
i -= 1
j -= 1
elif T[i][j] == 2:
res[0] = "−" + res[0]
res[1] = X[j - 1] + res[1]
j -= 1
elif T[i][j] == 0:
res[0] = X[i - 1] + res[0]
res[1] = "−" + res[1]
i -= i