Hello, I am trying to implement the Levenshtien distance algorithm in c# using the invoke code activity. I am new to using invoke code and c# in general. The c# implementation of the Levenshtien algorithm can be found below:
public static int EditDistance (string original, string modified)
{
int len_orig = original.Length;
int len_diff = modified.Length;
var matrix = new int[len_orig + 1, len_diff + 1];
for (int i = 0; i <= len_orig; i++)
matrix[i,0] = i;
for (int j = 0; j <= len_diff; j++)
matrix[0,j] = j;
for (int i = 1; i <= len_orig; i++) {
for (int j = 1; j <= len_diff; j++) {
int cost = modified[j - 1] == original[i - 1] ? 0 : 1;
var vals = new int[] {
matrix[i - 1, j] + 1,
matrix[i, j - 1] + 1,
matrix[i - 1, j - 1] + cost
};
matrix[i,j] = vals.Min ();
if (i > 1 && j > 1 && original[i - 1] == modified[j - 2] && original[i - 2] == modified[j - 1])
matrix[i,j] = Math.Min (matrix[i,j], matrix[i - 2, j - 2] + cost);
}
}
return matrix[len_orig, len_diff];
}
How would I adapt this code to work with the invoke code activity?