Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Correct

125Size
Leading solution size is 54.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
Code Input and Output
1
Pass
 
%%
p = [1 2 3 4 5;
     2 3 4 5 1;
     3 4 6 7 8;
     1 2 4 3 5;
     4 6 3 2 1];
v = 4;
out = [1 2 3 4 4;
       1 2 3 5 3;
       1 2 4 5 3;
       1 3 4 5 3;
       2 3 4 5 3]
assert(isequal(findRowPattern(p,v),out))
out =
     1     2     3     4     4
     1     2     3     5     3
     1     2     4     5     3
     1     3     4     5     3
     2     3     4     5     3
ans =
     1     2     3     4     4
     1     2     3     5     3
     1     2     4     5     3
     1     3     4     5     3
     2     3     4     5     3
2
Pass
 
%%
p = [1 2 3 4 9;
     2 3 1 4 8]
v = 4;
out = [1 2 3 4 2]
assert(isequal(findRowPattern(p,v),out))
p =
     1     2     3     4     9
     2     3     1     4     8
out =
     1     2     3     4     2
ans =
     1     2     3     4     2
3
Pass
 
%%
p = [1 2 3 4 9;
     2 3 1 4 8;
     3 4 2 7 1]
v = 3;
out = [1 2 3 3;
       1 2 4 3;
       1 3 4 3;
       2 3 4 3]
assert(isequal(findRowPattern(p,v),out))
p =
     1     2     3     4     9
     2     3     1     4     8
     3     4     2     7     1
out =
     1     2     3     3
     1     2     4     3
     1     3     4     3
     2     3     4     3
ans =
     1     2     3     3
     1     2     4     3
     1     3     4     3
     2     3     4     3
4
Pass
 
%%
p = [1 2 3 4 9;
     2 3 1 4 8]
v = 2;
out = [1 2 2;
       1 3 2;
       1 4 2;
       2 3 2;
       2 4 2;
       3 4 2]
assert(isequal(findRowPattern(p,v),out))
p =
     1     2     3     4     9
     2     3     1     4     8
out =
     1     2     2
     1     3     2
     1     4     2
     2     3     2
     2     4     2
     3     4     2
ans =
     1     2     2
     1     3     2
     1     4     2
     2     3     2
     2     4     2
     3     4     2
5
Pass
 
%%
p = [15 23 68 49 88;
     69 58 78 21 35;
     10 23 21 35 88;
     99 58 63 24 10;
     64 28 14 33 58;
     85 69 21 45 55;
     99 24 76 49 33;
     89 69 33 98 21;
     99 10 21 55 58;
     35 68 69 44 21;
     21 69 35 46 33];
v = 3;
out = [21 35 69 3;
     10 58 99 2;
     21 33 69 2]
assert(isequal(findRowPattern(p,v),out))
out =
    21    35    69     3
    10    58    99     2
    21    33    69     2
ans =
    21    35    69     3
    10    58    99     2
    21    33    69     2
6
Pass
 
%%
p = [15 23 68 49 88;
     69 58 78 21 35;
     10 23 21 35 88;
     99 58 63 24 10;
     64 28 14 33 58;
     85 69 21 45 55;
     99 24 76 49 33;
     89 69 33 98 21;
     99 10 21 55 58;
     35 68 69 44 21;
     21 69 35 46 33];
v = 2;
out = [21    69     5;
       21    35     4;
       35    69     3;
       10    21     2;
       10    58     2;
       10    99     2;
       21    33     2;
       21    55     2;
       21    58     2;
       23    88     2;
       24    99     2;
       33    69     2;
       58    99     2]
assert(isequal(findRowPattern(p,v),out))
out =
    21    69     5
    21    35     4
    35    69     3
    10    21     2
    10    58     2
    10    99     2
    21    33     2
    21    55     2
    21    58     2
    23    88     2
    24    99     2
    33    69     2
    58    99     2
ans =
    21    69     5
    21    35     4
    35    69     3
    10    21     2
    10    58     2
    10    99     2
    21    33     2
    21    55     2
    21    58     2
    23    88     2
    24    99     2
    33    69     2
    58    99     2