Cody

Problem 2309. Calculate the Damerau-Levenshtein distance between two strings.

Solution 1831277

Submitted on 30 May 2019
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Fail

Undefined function 'Damerau_Levenshtein' for input arguments of type 'char'. Error in Test1 (line 1) assert(isequal(Damerau_Levenshtein('mom','dad'),3));

2   Fail
assert(isequal(Damerau_Levenshtein('dogs','dog'),1)); % 1 deletion

Undefined function 'Damerau_Levenshtein' for input arguments of type 'char'. Error in Test2 (line 1) assert(isequal(Damerau_Levenshtein('dogs','dog'),1));

3   Fail
assert(isequal(Damerau_Levenshtein('true','true'),0)); % identity

Undefined function 'Damerau_Levenshtein' for input arguments of type 'char'. Error in Test3 (line 1) assert(isequal(Damerau_Levenshtein('true','true'),0));

4   Fail
assert(isequal(Damerau_Levenshtein('true','false'),4)); % 1 insertion, 3 substitutions

Undefined function 'Damerau_Levenshtein' for input arguments of type 'char'. Error in Test4 (line 1) assert(isequal(Damerau_Levenshtein('true','false'),4));

5   Fail
assert(isequal(Damerau_Levenshtein('abc','ca'),2)); % 1 deletion, 1 transposition

Undefined function 'Damerau_Levenshtein' for input arguments of type 'char'. Error in Test5 (line 1) assert(isequal(Damerau_Levenshtein('abc','ca'),2));

6   Fail
assert(isequal(Damerau_Levenshtein('tee','tree'),1));

Undefined function 'Damerau_Levenshtein' for input arguments of type 'char'. Error in Test6 (line 1) assert(isequal(Damerau_Levenshtein('tee','tree'),1));

7   Fail
assert(isequal(Damerau_Levenshtein('email','mails'),2));

Undefined function 'Damerau_Levenshtein' for input arguments of type 'char'. Error in Test7 (line 1) assert(isequal(Damerau_Levenshtein('email','mails'),2));

8   Fail