Cody

# Problem 93. Calculate the Levenshtein distance between two strings

Solution 125546

Submitted on 9 Aug 2012 by Richard Zapor
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))

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

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

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

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

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

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))
The text passage contains a series of test cases for a function that calculates the Levenshtein distance between two strings, with each test case providing the input strings and the expected result.
multiple_questions_with_answers
Given a text passage, determine:
    1. If it contains a mathematical question (including word problems or calculations)
    2. If an answer to that mathematical question is provided in the text

First, describe the content structure you found in 1-2 sentences.

Then provide your analysis in the following format:
TYPE: <one of the following values>
- NO_QUESTION
- SINGLE_QUESTION
- SINGLE_QUESTION_WITH_ANSWER
- MULTIPLE_QUESTIONS
- MULTIPLE_QUESTIONS_WITH_ANSWERS
system
Cody

# Problem 93. Calculate the Levenshtein distance between two strings

Solution 125546

Submitted on 9 Aug 2012 by Richard Zapor
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))

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

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

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

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

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

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))
user
The text passage contains a series of test cases for a function that calculates the Levenshtein distance between two strings, with each test case providing the input strings and the expected result.

TYPE: MULTIPLE_QUESTIONS_WITH_ANSWERS