Cody

# Problem 1032. compare strings

Solution 1932414

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

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

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

a = 116 104 105 115 b = 104 97 115 l1 = 4 l2 = 3 b = 104 97 115 0 d = 12 7 -10 115 d = 12 7 -10 115 d = 4

Assertion failed.

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

a = 97 99 103 116 97 99 103 116 97 99 103 116 b = 97 99 97 116 97 99 116 116 103 116 97 99 116 l1 = 12 l2 = 13 a = 97 99 103 116 97 99 103 116 97 99 103 116 0 d = 0 0 6 0 0 0 -13 0 -6 -17 6 17 -116 d = 6 -13 -6 -17 6 17 -116 d = 6

Assertion failed.

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

a = 102 114 97 99 116 97 112 101 114 116 111 114 110 105 115 101 109 b = 97 108 102 114 97 99 99 104 97 112 101 114 105 116 111 110 105 115 109 l1 = 17 l2 = 19 a = 102 114 97 99 116 97 112 101 114 116 111 114 110 105 115 101 109 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 = 115 112 114 105 110 103 b = 115 112 114 105 110 103 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 = 113 97 122 119 115 120 101 100 99 114 102 118 116 103 98 b = 113 97 122 119 115 109 101 100 99 118 102 114 l1 = 15 l2 = 12 b = 113 97 122 119 115 109 101 100 99 118 102 114 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))

### Community Treasure Hunt

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

Start Hunting!