Cody

Solution 1866293

Submitted on 5 Jul 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
assert(isequal(Damerau_Levenshtein('mom','dad'),3)); % 3 substitutions

Assertion failed.

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

Assertion failed.

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

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

Assertion failed.

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

Assertion failed.

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

Assertion failed.

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

Assertion failed.

8   Fail
assert(isequal(Damerau_Levenshtein('profit','gifts'),5));

Assertion failed.

9   Pass
% symmetry rnd=@()char(randi([97 122],1,randi([4 10]))); for k=1:10 str1=rnd(); str2=rnd(); a=Damerau_Levenshtein(str1,str2); b=Damerau_Levenshtein(str2,str1); assert(isequal(a,b)) end

10   Pass
% trinagle inequality rnd=@()char(randi([97 122],1,randi([4 10]))); for k=1:50 str1=rnd(); str2=rnd(); str3=rnd(); a=Damerau_Levenshtein(str2,str3); b=Damerau_Levenshtein(str3,str1); c=Damerau_Levenshtein(str1,str2); assert(a+b>=c) end