Cody

Problem 42845. generate number in particular way

Solution 2502536

Submitted on 9 Jun 2020
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 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))

n = 4 y = 1 5 5 5 5 5 5 5 5 5 ix = 2 y = 1 2 2 2 2 2 5 5 5 5 ix = 7 y = 1 2 2 2 2 2 3 3 5 5 ix = 9 y = 1 2 2 2 2 2 3 3 4 4 4 4 4 4 4 ix = 16 y = 1 2 2 2 2 2 3 3 4 4

2   Pass
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))

n = 6 y = 1 1 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 ix = 3 y = 1 1 2 2 2 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 ix = 6 y = 1 1 2 2 2 3 3 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 ix = 8 y = 1 1 2 2 2 3 3 4 4 4 4 4 4 4 7 7 7 7 7 7 7 7 ix = 15 y = 1 1 2 2 2 3 3 4 4 4 4 4 4 4 5 5 5 5 7 7 7 7 ix = 19 y = 1 1 2 2 2 3 3 4 4 4 4 4 4 4 5 5 5 5 6 6 6 6 6 6 ix = 25 y = 1 1 2 2 2 3 3 4 4 4 4 4 4 4 5 5 5 5 6 6 6 6

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

n = 100 y = Columns 1 through 29 1 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 Columns 30 through 42 101 101 101 101 101 101 101 101 101 101 101 101 101 ix = 2 y = Columns 1 through 29 1 2 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 Columns 30 through 42 101 101 101 101 101 101 101 101 101 101 101 101 101 ix = 3 y = Columns 1 through 29 1 2 3 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 Columns 30 through 42 101 101 101 101 101 101 101 101 101 101 101 101 101 ix = 4 y = Columns 1 through 29 1 2 3 4 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 Columns 30 through 42 101 101 101 101 101 101 101 101 101 101 101 101 101 ix = 5 y = Columns 1 through 29 1 2 3 4 5 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 Columns 30 through 42 101 101 101 101 101 101 101 101 101 101 101 101 101 ix = 6 y = Columns 1 through 29 1 2 3 4 5 6 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 Columns 30 through 42 101 101 101 101 101 101 101 101 101 101 101 101 101 ix = 7 y = Columns 1 through 29 1 2 3 4 5 6 7 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 Columns 30 through 42 101 101 101 101 101 101 101 101 101 101 101 101 101 ix = 8 y = Columns 1 through 29 1 2 3 4 5 6 7 8 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 Columns 30 through 42 101 101 101 101 101 101 101 101 101 101 101 101 101 ix = 9 y = Columns 1 through 29 1 2 3 4 5 6 7 8 9 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 Columns 30 through 42 101 101 101 101 101 101 101 101 101 101 101 101 101 ix = 10 y = Columns 1 through 29 1 2 3 4 5 6 7 8 9 10 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 Columns 30 through 42 101 101 101 101 101 101 101 101 101 101 101 101 101 ix = 11 y = Columns 1 through 29 1 2 3 4 5 6 7 8 9 10 11 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 Columns 30 through 42 101 101 101 101 101 101 101 101 101 101 101 101 101 ix = 12 y = Columns 1 through 29 1 2 3 4 5 6 7 8 9 10 11 12 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 Columns 30 through 42 101 101 101 101 101 101 101 101 101 101 101 101 101 ix = 13 y = Columns 1 through 29 1 2 3 4 5 6 7 8 9 10 11 12 13 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 Columns 30 through 42 101 101 101 101 101 101 101 101 101 101 101 101 101 ix = 14 y = Columns 1 through 29 1 2 3 4 5 6 7 8 9 10 11 12 13 14 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 Columns 30 through 42 101 101 101 101 101 101 101 101 101 101 101 101 101 ix = 15 y = Columns 1 through 29 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 101 101 101 101 101 101 101 101 101 101 101 101 101 101 Columns 30 through 42 101 101 101 101 101 101 101 101 101 101 101 101 101 ix = 16 y = Columns 1 through 29 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 101 101 101 101 101 101 101 101 101 101 101 101 101 Columns 30 through 42 101 101 101 101 101 101 101 101 101 101 101 101 101 ix = 17 y = Columns 1 through 29 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 101 101 101 101 101 101 101 101 101 101 101 101 Columns 30 through 42 101 101 101 101 101 101 101 101 101 101 101 101 101 ix = 18 y = Columns 1 through 29 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 101 101 101 101 101 101 101 101 101 101 101 Columns 30 through 42 101 101 101 101 101 101 101 101 101 101 101 101 101 ix = 19 y = Columns 1 through 29 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 101 101 101 101 101 101 101 101 101 101 Columns 30 through 42 101 101 101 101 101 101 101 101 101 101 101 101 101 ix = 20 y = Columns 1 through 29 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 101 101 101 101 101 101 101 101 101 Columns 30 through 42 101 101 101 101 101 101 101 101 101 101 101 101 101 ix = 21 y = Columns 1 through 29 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 101 101 101 101 101 101 101 101 Columns 30 through 42 101 101 101 101 101 101 101 101 101 101 101 101 101 ix = 22 y = Columns 1 through 29 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 101 101 101 101 101 101 101 Columns 30 through 42 101 101 101 101 101 101 101 101 101 101 101 101 101 ix = 23 y = Columns 1 through 29 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 101 101 101 101 101 101 Columns 30 through 42 101 101 101 101 101 101 101 101 101 101 101 101 101 ix = 24 y = Columns 1 through 29 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 101 101 101 101 101 Columns 30 through 42 101 101 101 101 101 101 101 101 101 101 101 101 101 ix = 25 y = Columns 1 through 29 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 101 101 101 101 Columns 30 through 42 101 101 101 101 101 101 101 101 101 101 101 101 101 ix = 26 y = Columns 1 through 29 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 101 101 101 Columns 30 through 42 101 101 101 101 101 101 101 101 101 101 101 101 101 ix = 27 y = Columns 1 through 29 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 101 101 Columns 30 through 42 101 101 101 101 101 101 101 101 101 101 101 101 101 ix = 28 y = Columns 1 through 29 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 101 Columns 30 through 42 101 101 101 101 101 101 101 101 101 101 101 101 101 ix = 29 y = Columns 1 through 29 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 Columns 30 through 42 101 101 101 101 101 101 101 101 101 101 101 101 101 ix = 30 y = Columns 1 through 29 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 Columns 30 through 42 30 101 101 101 101 101 101 101 101 101 101 101 101 ix = 31 y = Columns 1 through 29 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 ...

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))

n = 5 y = 1 1 1 6 6 6 6 6 6 6 6 6 6 ix = 4 y = 1 1 1 2 6 6 6 6 6 6 6 6 6 ix = 5 y = 1 1 1 2 3 3 6 6 6 6 6 6 6 ix = 7 y = 1 1 1 2 3 3 4 4 4 4 4 4 6 ix = 13 y = 1 1 1 2 3 3 4 4 4 4 4 4 6

Assertion failed.

5   Pass
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))

n = 10 y = 1 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 ix = 2 y = 1 2 2 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 ix = 4 y = 1 2 2 3 3 3 11 11 11 11 11 11 11 11 11 11 11 11 11 11 ix = 7 y = 1 2 2 3 3 3 4 4 4 4 11 11 11 11 11 11 11 11 11 11 ix = 11 y = 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 11 11 11 11 11 ix = 16 y = 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 6 6 6 6 6 6 ix = 22 y = 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 6 6 6 6 6

6   Pass
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))

n = 6 y = 1 1 1 7 7 7 7 7 7 7 7 7 7 ix = 4 y = 1 1 1 2 7 7 7 7 7 7 7 7 7 ix = 5 y = 1 1 1 2 3 3 3 3 7 7 7 7 7 ix = 9 y = 1 1 1 2 3 3 3 3 4 7 7 7 7 ix = 10 y = 1 1 1 2 3 3 3 3 4 5 5 5 5 5 ix = 15 y = 1 1 1 2 3 3 3 3 4 5 5 5 5

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!