Cody

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

Solution 1948436

Submitted on 25 Sep 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   Pass
s1 = 'I do not like MATLAB'; s2 = 'I love MATLAB a lot'; d_correct = 4; assert(isequal(modlevenshtein(s1,s2),d_correct))

t1 = ' AABILMTdeiklnoot' t2 = ' AABILMTaellootv' index = 1 2 3 4 index = 1 2 3 index = 1 2 index = 1 index = 1 2 index = 1 index = 1 index = 1 index = 1 index = 1 index = 1 index = [] index = 2 index = 4 index = [] index = 5 6 index = 5 index = 5 index = []

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

t1 = ' ?Wbcddddeeeeehhiinoorsttw' t2 = ' ?Cabcddddeeeeeehhiillnnooorstttuwwy'

Assertion failed.

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

Assertion failed.

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

Assertion failed.

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

t1 = ' ',Tabbbdeeeehhiiiillmmnnoopsssstttuuy' t2 = ' ',Tabbbdeeeehhiiiillmmnnoopsssstttuuy'

Assertion failed.

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

t1 = ' ,,,,,...Teeeeegghiinnnoorsstttttw' t2 = ' ,,,,...Teeeggiinnnoossttttw' index = 1 2 3 4 index = 1 2 3 index = 1 2 index = 2 3 4 5 6 index = 2 3 4 5 index = 2 3 4 index = 2 3 index = 3 4 5 index = 3 4 index = 3 index = 3 index = 3 4 5 6 7 index = 3 4 5 6 index = 3 4 5 index = 5 6 index = 5 index = 6 7 index = 6 index = 6 7 8 index = 6 7 index = 6 index = 6 7 index = 6 index = 7 8 index = 7 index = 7 8 9 10 11 index = 7 8 9 10 index = 7 8 9 index = 7 8 index = 8

Assertion failed.

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