Cody

Problem 846. Calculate the Hamming distance between two strings

Solution 3226538

Submitted on 15 Oct 2020
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 = 'Sunday'; s2 = 'Monday'; d_correct = 2; assert(isequal(hamming(s1,s2),d_correct))

Undefined function 'lenth' for input arguments of type 'logical'. Error in hamming (line 3) d = lenth(x)-sum(x); Error in Test1 (line 4) assert(isequal(hamming(s1,s2),d_correct))

2   Fail
s1 = 'Cody is not fun?'; s2 = 'Cody is awesome!'; d_correct = 8; assert(isequal(hamming(s1,s2),d_correct))

Undefined function 'lenth' for input arguments of type 'logical'. Error in hamming (line 3) d = lenth(x)-sum(x); Error in Test2 (line 4) assert(isequal(hamming(s1,s2),d_correct))

3   Fail
s1 = 'I do not like MATLAB'; s2 = 'I really love MATLAB'; d_correct = 8; assert(isequal(hamming(s1,s2),d_correct))

Undefined function 'lenth' for input arguments of type 'logical'. Error in hamming (line 3) d = lenth(x)-sum(x); Error in Test3 (line 4) assert(isequal(hamming(s1,s2),d_correct))

4   Fail
s1 = 'abcdefghijklmnopqrstuvwxyz'; s2 = 'AbcdEfghIjklmnOpqrstUvwxyz'; d_correct = 5; assert(isequal(hamming(s1,s2),d_correct))

Undefined function 'lenth' for input arguments of type 'logical'. Error in hamming (line 3) d = lenth(x)-sum(x); Error in Test4 (line 4) assert(isequal(hamming(s1,s2),d_correct))

5   Fail
s1 = '1234567891011121314151617181920'; s2 = '2019181716151413121110987654321'; d_correct = 27; assert(isequal(hamming(s1,s2),d_correct))

Undefined function 'lenth' for input arguments of type 'logical'. Error in hamming (line 3) d = lenth(x)-sum(x); Error in Test5 (line 4) assert(isequal(hamming(s1,s2),d_correct))

6   Fail
s1 = 'race car'; s2 = 'rac ecar'; d_correct = 2; assert(isequal(hamming(s1,s2),d_correct))

Undefined function 'lenth' for input arguments of type 'logical'. Error in hamming (line 3) d = lenth(x)-sum(x); Error in Test6 (line 4) assert(isequal(hamming(s1,s2),d_correct))

7   Fail
s1 = 'Are these strings identical?'; s2 = 'Are these strings identical?'; d_correct = 0; assert(isequal(hamming(s1,s2),d_correct))

Undefined function 'lenth' for input arguments of type 'logical'. Error in hamming (line 3) d = lenth(x)-sum(x); Error in Test7 (line 4) assert(isequal(hamming(s1,s2),d_correct))

8   Fail
s1 = ''; s2 = ''; d_correct = 0; assert(isequal(hamming(s1,s2),d_correct))

Undefined function 'lenth' for input arguments of type 'logical'. Error in hamming (line 3) d = lenth(x)-sum(x); Error in Test8 (line 4) assert(isequal(hamming(s1,s2),d_correct))

Suggested Problems

More from this Author44

Community Treasure Hunt

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

Start Hunting!