Cody

# Problem 67. Find common elements in matrix rows

Solution 1879651

Submitted on 20 Jul 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
x = []; y_correct = []; assert(isequal(common_by_row(x),y_correct))

t = 0×1 empty double column vector

Output argument "y" (and maybe others) not assigned during call to "common_by_row". Error in Test1 (line 3) assert(isequal(common_by_row(x),y_correct))

2   Fail
x = [1e100; 1e100]; y_correct = [1e100]; assert(isequal(common_by_row(x),y_correct))

t = 1.0000e+100 ans = 1 2

Output argument "y" (and maybe others) not assigned during call to "common_by_row". Error in Test2 (line 3) assert(isequal(common_by_row(x),y_correct))

3   Fail
x = [1; 2]; y_correct = []; assert(isequal(common_by_row(x),y_correct))

t = 1 2 ans = 1 ans = 2

Output argument "y" (and maybe others) not assigned during call to "common_by_row". Error in Test3 (line 3) assert(isequal(common_by_row(x),y_correct))

4   Fail
x = ones(10); y_correct = [1]; assert(isequal(common_by_row(x),y_correct))

t = 1 ans = 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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100

Output argument "y" (and maybe others) not assigned during call to "common_by_row". Error in Test4 (line 3) assert(isequal(common_by_row(x),y_correct))

5   Fail
x = magic(10); y_correct = []; assert(isequal(common_by_row(x),y_correct))

t = 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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 ans = 21 ans = 35 ans = 44 ans = 3 ans = 17 ans = 18 ans = 22 ans = 31 ans = 45 ans = 9 ans = 10 ans = 19 ans = 28 ans = 32 ans = 41 ans = 42 ans = 6 ans = 20 ans = 24 ans = 33 ans = 34 ans = 43 ans = 7 ans = 16 ans = 25 ans = 76 ans = 90 ans = 94 ans = 58 ans = 67 ans = 68 ans = 77 ans = 86 ans = 95 ans = 59 ans = 60 ans = 69 ans = 78 ans = 87 ans = 91 ans = 92 ans = 56 ans = 70 ans = 79 ans = 88 ans = 89 ans = 93 ans = 57 ans = 66 ans = 80 ans = 71 ans = 85 ans = 99 ans = 53 ans = 62 ans = 63 ans = 72 ans = 81 ans = 100 ans = 54 ans = 55 ans = 64 ans = 73 ans = 82 ans = 96 ans = 97 ans = 51 ans = 65 ans = 74 ans = 83 ans = 84 ans = 98 ans = 52 ans = 61 ans = 75 ans = 26 ans = 40 ans = 49 ans = 8 ans = 12 ans = 13 ans = 27 ans = 36 ans = 50 ans = 4 ans = 5 ans = 14 ans = 23 ans = 37 ans = 46 ans = 47 ans = 1 ans = 15 ans = 29 ans = 38 ans = 39 ans = 48 ans = 2 ans = 11 ans = 30

Output argument "y" (and maybe others) not assigned during call to "common_by_row". Error in Test5 (line 3) assert(isequal(common_by_row(x),y_correct))

6   Fail
x = wilkinson(9); y_correct = [0 1]; assert(isequal(common_by_row(x),y_correct))

t = 0 1 2 3 4 ans = 3 4 5 6 7 8 9 13 14 15 16 17 18 19 23 24 25 26 27 28 29 33 34 35 36 37 38 39 41 43 44 45 46 47 48 49 53 54 55 56 57 58 59 63 64 65 66 67 68 69 73 74 75 76 77 78 79 ans = 2 10 12 20 22 30 31 32 40 42 50 51 52 60 62 70 72 80 ans = 21 61 ans = 11 71 ans = 1 81

Output argument "y" (and maybe others) not assigned during call to "common_by_row". Error in Test6 (line 3) assert(isequal(common_by_row(x),y_correct))

7   Fail
x = [3 -2 1 NaN; NaN 0 -2 3]; y_correct = [-2 3]; assert(isequal(common_by_row(x),y_correct))

t = -2 0 1 3 NaN NaN ans = 3 6 ans = 4 ans = 5 ans = 1 8 ans = 0×1 empty double column vector ans = 0×1 empty double column vector

Output argument "y" (and maybe others) not assigned during call to "common_by_row". Error in Test7 (line 3) assert(isequal(common_by_row(x),y_correct))