Cody

# Problem 848. Calculate a modified Levenshtein distance between two strings

Solution 2099900

Submitted on 20 Jan 2020 by Asif Newaz
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 = 'I do not like MATLAB'; s2 = 'I love MATLAB a lot'; d_correct = 4; assert(isequal(modlevenshtein(s1,s2),d_correct))

y = 0 1 2 3 4 5 1 0 1 2 3 4 2 1 1 2 3 4 3 2 2 2 3 3 4 3 3 3 3 4 5 4 4 4 4 4

2   Pass
s1 = 'Which words need to be edited?'; s2 = 'Can you tell which words need to be edited?'; d_correct = 3; assert(isequal(modlevenshtein(s1,s2),d_correct))

y = 0 1 2 3 4 5 6 1 1 2 3 4 5 6 2 2 2 3 4 5 6 3 3 3 3 4 5 6 4 3 4 4 4 5 6 5 4 3 4 5 5 6 6 5 4 3 4 5 6 7 6 5 4 3 4 5 8 7 6 5 4 3 4 9 8 7 6 5 4 3

3   Pass
s1 = 'Are these strings identical?'; s2 = 'These strings are not identical!'; d_correct = 3; assert(isequal(modlevenshtein(s1,s2),d_correct))

y = 0 1 2 3 4 1 1 1 2 3 2 2 2 1 2 3 2 3 2 2 4 3 3 3 3 5 4 4 4 3

4   Pass
s1 = 'Settlers of Catan is my favorite game'; s2 = 'Tic-tac-toe is also one of my favorite games'; d_correct = 6; assert(isequal(modlevenshtein(s1,s2),d_correct))

y = 0 1 2 3 4 5 6 7 1 1 2 3 4 5 6 7 2 2 2 3 3 4 5 6 3 3 3 3 4 4 5 6 4 4 4 4 4 5 5 6 5 5 4 5 5 5 6 6 6 6 5 5 6 5 6 7 7 7 6 6 6 6 5 6 8 8 7 7 7 7 6 6

5   Pass
s1 = 'This one should be simple, but maybe it isn''t'; s2 = 'This one should be simple, but maybe it isn''t'; d_correct = 0; assert(isequal(modlevenshtein(s1,s2),d_correct))

y = 0 1 2 3 4 5 6 7 8 9 1 0 1 2 3 4 5 6 7 8 2 1 0 1 2 3 4 5 6 7 3 2 1 0 1 2 3 4 5 6 4 3 2 1 0 1 2 3 4 5 5 4 3 2 1 0 1 2 3 4 6 5 4 3 2 1 0 1 2 3 7 6 5 4 3 2 1 0 1 2 8 7 6 5 4 3 2 1 0 1 9 8 7 6 5 4 3 2 1 0

6   Pass
s1 = 'Testing, testing, one, two, three,...'; s2 = 'Testing, testing, one, two,...'; d_correct = 1; assert(isequal(modlevenshtein(s1,s2),d_correct))

y = 0 1 2 3 4 5 1 0 1 2 3 4 2 1 0 1 2 3 3 2 1 0 1 2 4 3 2 1 0 1

7   Pass
s1 = 'How many edits do you think there are in this example? I don''t know!'; s2 = 'Well, it is hard to tell how many edits are required because there are big differences in the two strings.'; d_correct = 15; assert(isequal(modlevenshtein(s1,s2),d_correct))

y = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 2 2 2 3 4 5 6 7 8 9 10 11 12 13 14 3 3 3 3 4 5 6 7 8 9 10 11 12 13 14 4 4 4 4 4 5 6 7 8 9 10 11 12 13 14 5 5 5 5 5 5 6 7 8 9 10 11 12 13 14 6 6 6 6 6 6 6 7 8 9 10 11 12 13 14 7 6 7 7 7 7 7 7 8 9 10 11 12 13 14 8 7 6 7 8 8 8 8 8 9 10 11 12 13 14 9 8 7 6 7 8 9 9 9 9 10 11 12 13 14 10 9 8 7 7 8 9 10 9 10 10 11 12 13 14 11 10 9 8 8 8 9 10 10 10 11 11 12 13 14 12 11 10 9 9 9 9 10 11 11 11 12 12 13 14 13 12 11 10 10 10 10 9 10 11 12 12 13 13 14 14 13 12 11 11 11 11 10 9 10 11 12 13 14 14 15 14 13 12 12 12 12 11 10 10 11 12 13 14 15 16 15 14 13 13 13 13 12 11 11 11 12 13 14 15 17 16 15 14 14 14 14 13 12 11 12 12 13 14 15 18 17 16 15 15 15 15 14 13 12 12 13 13 14 15 19 18 17 16 16 16 16 15 14 13 13 13 14 14 15 20 19 18 17 17 17 17 16 15 14 14 14 14 15 15

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!