Cody

# Problem 93. Calculate the Levenshtein distance between two strings

Solution 1912787

Submitted on 26 Aug 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
s1 = 'kitten'; s2 = 'sitting'; d_correct = 3; assert(isequal(levenshtein(s1,s2),d_correct))

Unable to perform assignment because the size of the left side is 7-by-1 and the size of the right side is 1-by-6. Error in levenshtein (line 5) D(:,1)=1:ls1; Error in Test1 (line 5) assert(isequal(levenshtein(s1,s2),d_correct))

2   Fail
s1 = 'Saturday'; s2 = 'Sunday'; d_correct = 3; assert(isequal(levenshtein(s1,s2),d_correct))

Unable to perform assignment because the size of the left side is 9-by-1 and the size of the right side is 1-by-8. Error in levenshtein (line 5) D(:,1)=1:ls1; Error in Test2 (line 4) assert(isequal(levenshtein(s1,s2),d_correct))

3   Fail
s1 = 'MATLAB rocks!'; s2 = 'MathWorks'; d_correct = 9; assert(isequal(levenshtein(s1,s2),d_correct))

Unable to perform assignment because the size of the left side is 14-by-1 and the size of the right side is 1-by-13. Error in levenshtein (line 5) D(:,1)=1:ls1; Error in Test3 (line 4) assert(isequal(levenshtein(s1,s2),d_correct))

4   Fail
s1 = 'Four score and seven years ago'; s2 = 'Eighty seven years before today'; d_correct = 25; assert(isequal(levenshtein(s1,s2),d_correct))

Unable to perform assignment because the size of the left side is 31-by-1 and the size of the right side is 1-by-30. Error in levenshtein (line 5) D(:,1)=1:ls1; Error in Test4 (line 4) assert(isequal(levenshtein(s1,s2),d_correct))

5   Fail
s1 = 'Row row row your boat'; s2 = 'Gently down the stream'; d_correct = 18; assert(isequal(levenshtein(s1,s2),d_correct))

Unable to perform assignment because the size of the left side is 22-by-1 and the size of the right side is 1-by-21. Error in levenshtein (line 5) D(:,1)=1:ls1; Error in Test5 (line 4) assert(isequal(levenshtein(s1,s2),d_correct))

6   Fail
s1 = 'ninety-nine bottles of beer on the wall'; s2 = 'eighty-six bottles of beer on the wall'; d_correct = 6; assert(isequal(levenshtein(s1,s2),d_correct))

Unable to perform assignment because the size of the left side is 40-by-1 and the size of the right side is 1-by-39. Error in levenshtein (line 5) D(:,1)=1:ls1; Error in Test6 (line 4) assert(isequal(levenshtein(s1,s2),d_correct))

7   Fail
s1 = 'these are the times that try men''s souls'; s2 = 'soulwise, these are trying times'; d_correct = 27; assert(isequal(levenshtein(s1,s2),d_correct))

Unable to perform assignment because the size of the left side is 41-by-1 and the size of the right side is 1-by-40. Error in levenshtein (line 5) D(:,1)=1:ls1; Error in Test7 (line 4) assert(isequal(levenshtein(s1,s2),d_correct))