Cody

Solution 1846619

Submitted on 11 Jun 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
A = 1; IND = 1; b = 1; y_correct = [1;1]; assert(isequal(insertRows(A, IND, b), y_correct))

A = 1 1

2   Fail
A = [0 0; 1 1]; IND = [1 1 1 2]; b = NaN; y_correct = [0 0;NaN NaN;NaN NaN;NaN NaN;1 1;NaN NaN]; assert(isequalwithequalnans(insertRows(A, IND, b), y_correct))

A = 0 0 NaN NaN NaN NaN

Assertion failed.

3   Fail
A = [1 1; 3 3; 4 4]; IND = [1 3]; b = [2 2; 5 5]; y_correct = [1 1;2 2;3 3;4 4;5 5]; assert(isequal(insertRows(A, IND, b), y_correct))

A = 1 1 2 2 4 4 2 2 A = 1 1 5 5 4 4 5 5 A = 1 1 2 2 4 4 2 2 A = 1 1 5 5 4 4 5 5

Assertion failed.

4   Fail
A = (1:2:10)'; IND = 1:5; b = (2:2:10)'; y_correct = (1:10)'; assert(isequal(insertRows(A, IND, b), y_correct))

A = 1 2 2 2 2 2 A = 1 4 4 4 4 4 A = 1 6 6 6 6 6 A = 1 8 8 8 8 8 A = 1 10 10 10 10 10

Assertion failed.

5   Fail
A = zeros(10,5); IND = [3,7]; b = rand(2,5); y_correct = [zeros(3,5); b(1,:); zeros(4,5); b(2,:); zeros(3,5)]; assert(isequal(insertRows(A, IND, b), y_correct))

A = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.1514 0.1514 0.1514 0.1514 0.1514 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.1514 0.1514 0.1514 0.1514 0.1514 0 0 0 0 0 0 0 0 0 0 A = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.1664 0.1664 0.1664 0.1664 0.1664 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.1664 0.1664 0.1664 0.1664 0.1664 0 0 0 0 0 0 0 0 0 0 A = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.1086 0.1086 0.1086 0.1086 0.1086 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.1086 0.1086 0.1086 0.1086 0.1086 0 0 0 0 0 0 0 0 0 0 A = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.7110 0.7110 0.7110 0.7110 0.7110 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.7110 0.7110 0.7110 0.7110 0.7110 0 0 0 0 0 0 0 0 0 0 A = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.5751 0.5751 0.5751 0.5751 0.5751 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.5751 0.5751 0.5751 0.5751 0.5751 0 0 0 0 0 0 0 0 0 0 A = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.8974 0.8974 0.8974 0.8974 0.8974 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.8974 0.8974 0.8974 0.8974 0.8974 0 0 0 0 0 0 0 0 0 0 A = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.5907 0.5907 0.5907 0.5907 0.5907 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.5907 0.5907 0.5907 0.5907 0.5907 0 0 0 0 0 0 0 0 0 0 A = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.5076 0.5076 0.5076 0.5076 0.5076 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.5076 0.5076 0.5076 0.5076 0.5076 0 0 0 0 0 0 0 0 0 0 A = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.5060 0.5060 0.5060 0.5060 0.5060 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.5060 0.5060 0.5060 0.5060 0.5060 0 0 0 0 0 0 0 0 0 0 A = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.2953 0.2953 0.2953 0.2953 0.2953 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.2953 0.2953 0.2953 0.2953 0.2953 0 0 0 0 0 0 0 0 0 0

Assertion failed.

6   Pass
assert(isempty(strfind(evalc('type insertRows'), 'regexp')));

Suggested Problems

More from this Author1