Cody

# Problem 93. Calculate the Levenshtein distance between two strings

Solution 1936904

Submitted on 15 Sep 2019 by ChanXy
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   Pass
s1 = 'kitten'; s2 = 'sitting'; d_correct = 3; assert(isequal(levenshtein(s1,s2),d_correct))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In levenshtein (line 2) In ScoringEngineTestPoint1 (line 5) In solutionTest (line 3)]

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

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In levenshtein (line 2) In ScoringEngineTestPoint2 (line 4) In solutionTest (line 5)]

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

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In levenshtein (line 2) In ScoringEngineTestPoint3 (line 4) In solutionTest (line 7)]

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

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In levenshtein (line 2) In ScoringEngineTestPoint4 (line 4) In solutionTest (line 9)]

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

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In levenshtein (line 2) In ScoringEngineTestPoint5 (line 4) In solutionTest (line 11)]

6   Pass
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))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In levenshtein (line 2) In ScoringEngineTestPoint6 (line 4) In solutionTest (line 13)]

7   Pass
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))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In levenshtein (line 2) In ScoringEngineTestPoint7 (line 4) In solutionTest (line 15)]