31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
matrix[i-1][j-1] + nCost // Substitution
);
if (i > 1 && j > 1 && s1[i] == s2[j-1] && s1[i-1] == s2[j]) {
matrix[i][j] = Math.min(matrix[i][j], matrix[i-2][j-2] + nCost); // Transposition
}
}
}
console.log(s2 + ": " + matrix[nLen1][nLen2]);
return matrix[nLen1][nLen2];
}
catch (e) {
helpers.logerror(e);
}
},
|
|
|
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
matrix[i-1][j-1] + nCost // Substitution
);
if (i > 1 && j > 1 && s1[i] == s2[j-1] && s1[i-1] == s2[j]) {
matrix[i][j] = Math.min(matrix[i][j], matrix[i-2][j-2] + nCost); // Transposition
}
}
}
//console.log(s2 + ": " + matrix[nLen1][nLen2]);
return matrix[nLen1][nLen2];
}
catch (e) {
helpers.logerror(e);
}
},
|