Cody

Solution 2098907

Submitted on 19 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 = 'Sunday'; s2 = 'Monday'; d_correct = 2; assert(isequal(hamming(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 2 3 4 5 4 4 4 3 2 3 4 5 5 5 4 3 2 3 6 6 6 5 4 3 2

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

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

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

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

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

y = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 2 2 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 3 3 2 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 4 4 3 2 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 5 5 4 3 2 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 6 6 5 4 3 3 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 7 7 6 5 4 4 3 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 8 8 7 6 5 5 4 3 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 9 9 8 7 6 6 5 4 3 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 10 10 9 8 7 7 6 5 4 4 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 11 11 10 9 8 8 7 6 5 5 4 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 12 12 11 10 9 9 8 7 6 6 5 4 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 13 13 12 11 10 10 9 8 7 7 6 5 4 3 4 5 6 7 8 9 10 11 12 13 14 15 16 14 14 13 12 11 11 10 9 8 8 7 6 5 4 3 4 5 6 7 8 9 10 11 12 13 14 15 15 15 14 13 12 12 11 10 9 9 8 7 6 5 4 4 5 6 7 8 9 10 11 12 13 14 15 16 16 15 14 13 13 12 11 10 10 9 8 7 6 5 5 4 5 6 7 8 9 10 11 12 13 14 17 17 16 15 14 14 13 12 11 11 10 9 8 7 6 6 5 4 5 6 7 8 9 10 11 12 13 18 18 17 16 15 15 14 13 12 12 11 10 9 8 7 7 6 5 4 5 6 7 8 9 10 11 12 19 19 18 17 16 16 15 14 13 13 12 11 10 9 8 8 7 6 5 4 5 6 7 8 9 10 11 20 20 19 18 17 17 16 15 14 14 13 12 11 10 9 9 8 7 6 5 4 5 6 7 8 9 10 21 21 20 19 18 18 17 16 15 15 14 13 12 11 10 10 9 8 7 6 5 5 6 7 8 9 10 22 22 21 20 19 19 18 17 16 16 15 14 13 12 11 11 10 9 8 7 6 6 5 6 7 8 9 23 23 22 21 20 20 19 18 17 17 16 15 14 13 12 12 11 10 9 8 7 7 6 5 6 7 8 24 24 23 22 21 21 20 19 18 18 17 16 15 14 13 13 12 11 10 9 8 8 7 6 5 6 7 25 25 24 23 22 22 21 20 19 19 18 17 16 15 14 14 13 12 11 10 9 9 8 7 6 5 6 26 26 25 24 23 23 22 21 20 20 19 18 17 16 15 15 14 13 12 11 10 10 9 8 7 6 5

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

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

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

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

y = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 2 1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 3 2 1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 4 3 2 1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 6 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 7 6 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 8 7 6 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 9 8 7 6 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 10 9 8 7 6 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 11 10 9 8 7 6 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 12 11 10 9 8 7 6 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 10 11 12 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 10 11 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 10 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 2 3 4 5 6 7 8 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 2 3 4 5 6 7 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 2 3 4 5 6 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 2 3 4 5 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 2 3 4 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 2 3 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 2 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

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

y = 0