Cody

Problem 1035. Generate a vector like 1,2,2,3,3,3,4,4,4,4

Solution 2988187

Submitted on 24 Sep 2020 by David Bermudez
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
x = 2; y_correct = [1 2 2]; assert(isequal(your_fcn_name(x),y_correct))

cont = 0 cont = 1 cont = 2 cont = 3

2   Pass
x = 5; y_correct = [1 2 2 3 3 3 4 4 4 4 5 5 5 5 5]; assert(isequal(your_fcn_name(x),y_correct))

cont = 0 cont = 1 cont = 2 cont = 3 cont = 4 cont = 5 cont = 6 cont = 7 cont = 8 cont = 9 cont = 10 cont = 11 cont = 12 cont = 13 cont = 14 cont = 15

3   Pass
x = 10; y_correct = [1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 ... 6 6 6 6 6 6 7 7 7 7 7 7 7 8 8 8 8 8 8 8 8 ... 9 9 9 9 9 9 9 9 9 10 10 10 10 10 10 10 10 10 10]; assert(isequal(your_fcn_name(x),y_correct))

cont = 0 cont = 1 cont = 2 cont = 3 cont = 4 cont = 5 cont = 6 cont = 7 cont = 8 cont = 9 cont = 10 cont = 11 cont = 12 cont = 13 cont = 14 cont = 15 cont = 16 cont = 17 cont = 18 cont = 19 cont = 20 cont = 21 cont = 22 cont = 23 cont = 24 cont = 25 cont = 26 cont = 27 cont = 28 cont = 29 cont = 30 cont = 31 cont = 32 cont = 33 cont = 34 cont = 35 cont = 36 cont = 37 cont = 38 cont = 39 cont = 40 cont = 41 cont = 42 cont = 43 cont = 44 cont = 45 cont = 46 cont = 47 cont = 48 cont = 49 cont = 50 cont = 51 cont = 52 cont = 53 cont = 54 cont = 55

4   Pass
x = 12; y_correct = [1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 ... 6 6 6 6 6 6 7 7 7 7 7 7 7 8 8 8 8 8 8 8 8 ... 9 9 9 9 9 9 9 9 9 10 10 10 10 10 10 10 10 10 10 ... 11 11 11 11 11 11 11 11 11 11 11 ... 12 12 12 12 12 12 12 12 12 12 12 12]; assert(isequal(your_fcn_name(x),y_correct))

cont = 0 cont = 1 cont = 2 cont = 3 cont = 4 cont = 5 cont = 6 cont = 7 cont = 8 cont = 9 cont = 10 cont = 11 cont = 12 cont = 13 cont = 14 cont = 15 cont = 16 cont = 17 cont = 18 cont = 19 cont = 20 cont = 21 cont = 22 cont = 23 cont = 24 cont = 25 cont = 26 cont = 27 cont = 28 cont = 29 cont = 30 cont = 31 cont = 32 cont = 33 cont = 34 cont = 35 cont = 36 cont = 37 cont = 38 cont = 39 cont = 40 cont = 41 cont = 42 cont = 43 cont = 44 cont = 45 cont = 46 cont = 47 cont = 48 cont = 49 cont = 50 cont = 51 cont = 52 cont = 53 cont = 54 cont = 55 cont = 56 cont = 57 cont = 58 cont = 59 cont = 60 cont = 61 cont = 62 cont = 63 cont = 64 cont = 65 cont = 66 cont = 67 cont = 68 cont = 69 cont = 70 cont = 71 cont = 72 cont = 73 cont = 74 cont = 75 cont = 76 cont = 77 cont = 78

5   Pass
x = 9; y_correct = [1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 ... 6 6 6 6 6 6 7 7 7 7 7 7 7 8 8 8 8 8 8 8 8 ... 9 9 9 9 9 9 9 9 9]; assert(isequal(your_fcn_name(x),y_correct))

cont = 0 cont = 1 cont = 2 cont = 3 cont = 4 cont = 5 cont = 6 cont = 7 cont = 8 cont = 9 cont = 10 cont = 11 cont = 12 cont = 13 cont = 14 cont = 15 cont = 16 cont = 17 cont = 18 cont = 19 cont = 20 cont = 21 cont = 22 cont = 23 cont = 24 cont = 25 cont = 26 cont = 27 cont = 28 cont = 29 cont = 30 cont = 31 cont = 32 cont = 33 cont = 34 cont = 35 cont = 36 cont = 37 cont = 38 cont = 39 cont = 40 cont = 41 cont = 42 cont = 43 cont = 44 cont = 45

6   Pass
x = 7; y_correct = [1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 ... 6 6 6 6 6 6 7 7 7 7 7 7 7]; assert(isequal(your_fcn_name(x),y_correct))

cont = 0 cont = 1 cont = 2 cont = 3 cont = 4 cont = 5 cont = 6 cont = 7 cont = 8 cont = 9 cont = 10 cont = 11 cont = 12 cont = 13 cont = 14 cont = 15 cont = 16 cont = 17 cont = 18 cont = 19 cont = 20 cont = 21 cont = 22 cont = 23 cont = 24 cont = 25 cont = 26 cont = 27 cont = 28

7   Pass
x = 15; y_correct = [1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 ... 6 6 6 6 6 6 7 7 7 7 7 7 7 8 8 8 8 8 8 8 8 ... 9 9 9 9 9 9 9 9 9 10 10 10 10 10 10 10 10 10 10 ... 11 11 11 11 11 11 11 11 11 11 11 ... 12 12 12 12 12 12 12 12 12 12 12 12 ... 13 13 13 13 13 13 13 13 13 13 13 13 13 ... 14 14 14 14 14 14 14 14 14 14 14 14 14 14 ... 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15]; assert(isequal(your_fcn_name(x),y_correct))

cont = 0 cont = 1 cont = 2 cont = 3 cont = 4 cont = 5 cont = 6 cont = 7 cont = 8 cont = 9 cont = 10 cont = 11 cont = 12 cont = 13 cont = 14 cont = 15 cont = 16 cont = 17 cont = 18 cont = 19 cont = 20 cont = 21 cont = 22 cont = 23 cont = 24 cont = 25 cont = 26 cont = 27 cont = 28 cont = 29 cont = 30 cont = 31 cont = 32 cont = 33 cont = 34 cont = 35 cont = 36 cont = 37 cont = 38 cont = 39 cont = 40 cont = 41 cont = 42 cont = 43 cont = 44 cont = 45 cont = 46 cont = 47 cont = 48 cont = 49 cont = 50 cont = 51 cont = 52 cont = 53 cont = 54 cont = 55 cont = 56 cont = 57 cont = 58 cont = 59 cont = 60 cont = 61 cont = 62 cont = 63 cont = 64 cont = 65 cont = 66 cont = 67 cont = 68 cont = 69 cont = 70 cont = 71 cont = 72 cont = 73 cont = 74 cont = 75 cont = 76 cont = 77 cont = 78 cont = 79 cont = 80 cont = 81 cont = 82 cont = 83 cont = 84 cont = 85 cont = 86 cont = 87 cont = 88 cont = 89 cont = 90 cont = 91 cont = 92 cont = 93 cont = 94 cont = 95 cont = 96 cont = 97 cont = 98 cont = 99 cont = 100 cont = 101 cont = 102 cont = 103 cont = 104 cont = 105 cont = 106 cont = 107 cont = 108 cont = 109 cont = 110 cont = 111 cont = 112 cont = 113 cont = 114 cont = 115 cont = 116 cont = 117 cont = 118 cont = 119 cont = 120

Suggested Problems

More from this Author17

Community Treasure Hunt

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

Start Hunting!