Cody

Problem 42845. generate number in particular way

Solution 1943028

Submitted on 19 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   Fail
a = [1 5 2 7]; m = 10; y_correct = [1 2 2 2 2 2 3 3 4 4]; assert(isequal(your_fcn_name(a,m),y_correct))

y = 1×4 cell array {[1]} {1×5 double} {1×2 double} {1×7 double}

Index in position 2 exceeds array bounds (must not exceed 4). Error in your_fcn_name (line 4) y = y(1,1:m) Error in Test1 (line 5) assert(isequal(your_fcn_name(a,m),y_correct))

2   Fail
a = [2 3 2 7 4 6]; m = 22; y_correct = [1 1 2 2 2 3 3 4 4 4 4 4 4 4 5 5 5 5 6 6 6 6]; assert(isequal(your_fcn_name(a,m),y_correct))

y = 1×6 cell array {1×2 double} {1×3 double} {1×2 double} {1×7 double} {1×4 double} {1×6 double}

Index in position 2 exceeds array bounds (must not exceed 6). Error in your_fcn_name (line 4) y = y(1,1:m) Error in Test2 (line 5) assert(isequal(your_fcn_name(a,m),y_correct))

3   Fail
a = ones(1,100); m = 42; y_correct = 1:42; assert(isequal(your_fcn_name(a,m),y_correct))

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

Assertion failed.

4   Fail
a = [3 1 2 6 1]; m = 13; y_correct = [1 1 1 2 3 3 4 4 4 4 4 4 5]; assert(isequal(your_fcn_name(a,m),y_correct))

y = 1×5 cell array {1×3 double} {[2]} {1×2 double} {1×6 double} {[5]}

Index in position 2 exceeds array bounds (must not exceed 5). Error in your_fcn_name (line 4) y = y(1,1:m) Error in Test4 (line 5) assert(isequal(your_fcn_name(a,m),y_correct))

5   Fail
a = 1:10; m = 20; y_correct = [1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 6 6 6 6 6]; assert(isequal(your_fcn_name(a,m),y_correct))

y = 1×10 cell array {[1]} {1×2 double} {1×3 double} {1×4 double} {1×5 double} {1×6 double} {1×7 double} {1×8 double} {1×9 double} {1×10 double}

Index in position 2 exceeds array bounds (must not exceed 10). Error in your_fcn_name (line 4) y = y(1,1:m) Error in Test5 (line 5) assert(isequal(your_fcn_name(a,m),y_correct))

6   Fail
a = [3 1 4 1 5 2]; m = 13; y_correct = [1 1 1 2 3 3 3 3 4 5 5 5 5]; assert(isequal(your_fcn_name(a,m),y_correct))

y = 1×6 cell array {1×3 double} {[2]} {1×4 double} {[4]} {1×5 double} {1×2 double}

Index in position 2 exceeds array bounds (must not exceed 6). Error in your_fcn_name (line 4) y = y(1,1:m) Error in Test6 (line 5) assert(isequal(your_fcn_name(a,m),y_correct))

Suggested Problems

More from this Author3

Community Treasure Hunt

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

Start Hunting!