Cody

# Problem 44266. Sort the prime numbers in each row of a 3x3 matrix

Solution 1564303

Submitted on 19 Jun 2018
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
A=[5 8 2 4;1 11 1 5] ; B_correct = [2 8 5 4;1 5 1 11]; assert(isequal(SrtPrimesInRows(A),B_correct))

b = 5 8 2 4 pIdx = 1×4 logical array 1 0 1 0 p = 5 2 b = 2 5

Unable to perform assignment because the size of the left side is 1-by-4 and the size of the right side is 1-by-2. Error in SrtPrimesInRows (line 8) B(r,:) = b Error in Test1 (line 3) assert(isequal(SrtPrimesInRows(A),B_correct))

2   Fail
A=[2 7 5; 1 11 2;2 2 2]; B_correct=[2 5 7;1 2 11;2 2 2]; assert(isequal(SrtPrimesInRows(A),B_correct))

b = 2 7 5 pIdx = 1×3 logical array 1 1 1 p = 2 7 5 b = 2 5 7 B = 2 5 7 1 11 2 2 2 2 b = 1 11 2 pIdx = 1×3 logical array 0 1 1 p = 11 2 b = 2 11

Unable to perform assignment because the size of the left side is 1-by-3 and the size of the right side is 1-by-2. Error in SrtPrimesInRows (line 8) B(r,:) = b Error in Test2 (line 3) assert(isequal(SrtPrimesInRows(A),B_correct))

3   Fail
A=[111 12 134;333 654 100000;112227 38 1]; B_correct=A; assert(isequal(SrtPrimesInRows(A),B_correct))

b = 111 12 134 pIdx = 1×3 logical array 0 0 0 p = 1×0 empty double row vector b = 1×0 empty double row vector

Unable to perform assignment because the size of the left side is 1-by-3 and the size of the right side is 1-by-0. Error in SrtPrimesInRows (line 8) B(r,:) = b Error in Test3 (line 3) assert(isequal(SrtPrimesInRows(A),B_correct))

### Community Treasure Hunt

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

Start Hunting!