Cody

# Problem 1032. compare strings

Solution 1932419

Submitted on 12 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   Fail
str1 = 'spring'; str2 = 'strange'; d_correct = 3; assert(isequal(findDifference(str1,str2),d_correct))

a = 103 105 110 112 114 115 b = 97 101 103 110 114 115 116 l1 = 6 l2 = 7 a = 103 105 110 112 114 115 0 d = 6 4 7 2 0 0 -116 d = 6 4 7 2 -116 d = 5

Assertion failed.

2   Fail
str1 = 'this'; str2 = 'has'; d_correct = 2; assert(isequal(findDifference(str1,str2),d_correct))

a = 104 105 115 116 b = 97 104 115 l1 = 4 l2 = 3 b = 97 104 115 0 d = 7 1 0 116 d = 7 1 116 d = 3

Assertion failed.

3   Pass
str1 = 'acgtacgtacgt'; str2 = 'acatacttgtact'; d_correct = 4; assert(isequal(findDifference(str1,str2),d_correct))

a = 97 97 97 99 99 99 103 103 103 116 116 116 b = 97 97 97 97 99 99 99 103 116 116 116 116 116 l1 = 12 l2 = 13 a = 97 97 97 99 99 99 103 103 103 116 116 116 0 d = 0 0 0 2 0 0 4 0 -13 0 0 0 -116 d = 2 4 -13 -116 d = 4

4   Fail
str1 = 'fractapertornisem'; str2 = 'alfracchaperitonism'; d_correct = 7; assert(isequal(findDifference(str1,str2),d_correct))

a = 97 97 99 101 101 102 105 109 110 111 112 114 114 114 115 116 116 b = 97 97 97 99 99 101 102 104 105 105 108 109 110 111 112 114 114 115 116 l1 = 17 l2 = 19 a = 97 97 99 101 101 102 105 109 110 111 112 114 114 114 115 116 116 0

Matrix dimensions must agree. Error in findDifference (line 11) d=a-b Error in Test4 (line 4) assert(isequal(findDifference(str1,str2),d_correct))

5   Pass
str1 = 'spring'; str2 = 'spring'; d_correct = 0; assert(isequal(findDifference(str1,str2),d_correct))

a = 103 105 110 112 114 115 b = 103 105 110 112 114 115 l1 = 6 l2 = 6 d = 0 0 0 0 0 0 d = 1×0 empty double row vector d = 0

6   Fail
str1 = 'qazwsxedcrfvtgb'; str2 = 'qazwsmedcvfr'; d_correct = 6; assert(isequal(findDifference(str1,str2),d_correct))

a = 97 98 99 100 101 102 103 113 114 115 116 118 119 120 122 b = 97 99 100 101 102 109 113 114 115 118 119 122 l1 = 15 l2 = 12 b = 97 99 100 101 102 109 113 114 115 118 119 122 0

Matrix dimensions must agree. Error in findDifference (line 11) d=a-b Error in Test6 (line 4) assert(isequal(findDifference(str1,str2),d_correct))