Cody

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

Solution 2028239

Submitted on 19 Nov 2019 by Ian O Neill
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))

vec1 = [] vec1 = 1 2 vec1 = 1 2 2 ans = 1 2 2

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

vec1 = [] vec1 = 1 2 3 4 5 vec1 = 1 2 3 4 5 2 3 4 5 vec1 = 1 2 3 4 5 2 3 4 5 3 4 5 vec1 = 1 2 3 4 5 2 3 4 5 3 4 5 4 5 vec1 = 1 2 3 4 5 2 3 4 5 3 4 5 4 5 5 ans = 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5

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

vec1 = [] vec1 = 1 2 3 4 5 6 7 8 9 10 vec1 = 1 2 3 4 5 6 7 8 9 10 2 3 4 5 6 7 8 9 10 vec1 = 1 2 3 4 5 6 7 8 9 10 2 3 4 5 6 7 8 9 10 3 4 5 6 7 8 9 10 vec1 = Columns 1 through 30 1 2 3 4 5 6 7 8 9 10 2 3 4 5 6 7 8 9 10 3 4 5 6 7 8 9 10 4 5 6 Columns 31 through 34 7 8 9 10 vec1 = Columns 1 through 30 1 2 3 4 5 6 7 8 9 10 2 3 4 5 6 7 8 9 10 3 4 5 6 7 8 9 10 4 5 6 Columns 31 through 40 7 8 9 10 5 6 7 8 9 10 vec1 = Columns 1 through 30 1 2 3 4 5 6 7 8 9 10 2 3 4 5 6 7 8 9 10 3 4 5 6 7 8 9 10 4 5 6 Columns 31 through 45 7 8 9 10 5 6 7 8 9 10 6 7 8 9 10 vec1 = Columns 1 through 30 1 2 3 4 5 6 7 8 9 10 2 3 4 5 6 7 8 9 10 3 4 5 6 7 8 9 10 4 5 6 Columns 31 through 49 7 8 9 10 5 6 7 8 9 10 6 7 8 9 10 7 8 9 10 vec1 = Columns 1 through 30 1 2 3 4 5 6 7 8 9 10 2 3 4 5 6 7 8 9 10 3 4 5 6 7 8 9 10 4 5 6 Columns 31 through 52 7 8 9 10 5 6 7 8 9 10 6 7 8 9 10 7 8 9 10 8 9 10 vec1 = Columns 1 through 30 1 2 3 4 5 6 7 8 9 10 2 3 4 5 6 7 8 9 10 3 4 5 6 7 8 9 10 4 5 6 Columns 31 through 54 7 8 9 10 5 6 7 8 9 10 6 7 8 9 10 7 8 9 10 8 9 10 9 10 vec1 = Columns 1 through 30 1 2 3 4 5 6 7 8 9 10 2 3 4 5 6 7 8 9 10 3 4 5 6 7 8 9 10 4 5 6 Columns 31 through 55 7 8 9 10 5 6 7 8 9 10 6 7 8 9 10 7 8 9 10 8 9 10 9 10 10 ans = Columns 1 through 30 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 Columns 31 through 55 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

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

vec1 = [] vec1 = 1 2 3 4 5 6 7 8 9 10 11 12 vec1 = 1 2 3 4 5 6 7 8 9 10 11 12 2 3 4 5 6 7 8 9 10 11 12 vec1 = Columns 1 through 30 1 2 3 4 5 6 7 8 9 10 11 12 2 3 4 5 6 7 8 9 10 11 12 3 4 5 6 7 8 9 Columns 31 through 33 10 11 12 vec1 = Columns 1 through 30 1 2 3 4 5 6 7 8 9 10 11 12 2 3 4 5 6 7 8 9 10 11 12 3 4 5 6 7 8 9 Columns 31 through 42 10 11 12 4 5 6 7 8 9 10 11 12 vec1 = Columns 1 through 30 1 2 3 4 5 6 7 8 9 10 11 12 2 3 4 5 6 7 8 9 10 11 12 3 4 5 6 7 8 9 Columns 31 through 50 10 11 12 4 5 6 7 8 9 10 11 12 5 6 7 8 9 10 11 12 vec1 = Columns 1 through 30 1 2 3 4 5 6 7 8 9 10 11 12 2 3 4 5 6 7 8 9 10 11 12 3 4 5 6 7 8 9 Columns 31 through 57 10 11 12 4 5 6 7 8 9 10 11 12 5 6 7 8 9 10 11 12 6 7 8 9 10 11 12 vec1 = Columns 1 through 30 1 2 3 4 5 6 7 8 9 10 11 12 2 3 4 5 6 7 8 9 10 11 12 3 4 5 6 7 8 9 Columns 31 through 60 10 11 12 4 5 6 7 8 9 10 11 12 5 6 7 8 9 10 11 12 6 7 8 9 10 11 12 7 8 9 Columns 61 through 63 10 11 12 vec1 = Columns 1 through 30 1 2 3 4 5 6 7 8 9 10 11 12 2 3 4 5 6 7 8 9 10 11 12 3 4 5 6 7 8 9 Columns 31 through 60 10 11 12 4 5 6 7 8 9 10 11 12 5 6 7 8 9 10 11 12 6 7 8 9 10 11 12 7 8 9 Columns 61 through 68 10 11 12 8 9 10 11 12 vec1 = Columns 1 through 30 1 2 3 4 5 6 7 8 9 10 11 12 2 3 4 5 6 7 8 9 10 11 12 3 4 5 6 7 8 9 Columns 31 through 60 10 11 12 4 5 6 7 8 9 10 11 12 5 6 7 8 9 10 11 12 6 7 8 9 10 11 12 7 8 9 Columns 61 through 72 10 11 12 8 9 10 11 12 9 10 11 12 vec1 = Columns 1 through 30 1 2 3 4 5 6 7 8 9 10 11 12 2 3 4 5 6 7 8 9 10 11 12 3 4 5 6 7 8 9 Columns 31 through 60 10 11 12 4 5 6 7 8 9 10 11 12 5 6 7 8 9 10 11 12 6 7 8 9 10 11 12 7 8 9 Columns 61 through 75 10 11 12 8 9 10 11 12 9 10 11 12 10 11 12 vec1 = Columns 1 through 30 1 2 3 4 5 6 7 8 9 10 11 12 2 3 4 5 6 7 8 9 10 11 12 3 4 5 6 7 8 9 Columns 31 through 60 10 11 12 4 5 6 7 8 9 10 11 12 5 6 7 8 9 10 11 12 6 7 8 9 10 11 12 7 8 9 Columns 61 through 77 10 11 12 8 9 10 11 12 9 10 11 12 10 11 12 11 12 vec1 = Columns 1 through 30 1 2 3 4 5 6 7 8 9 10 11 12 2 3 4 5 6 7 8 9 10 11 12 3 4 5 6 7 8 9 Columns 31 through 60 10 11 12 4 5 6 7 8 9 10 11 12 5 6 7 8 9 10 11 12 6 7 8 9 10 11 12 7 8 9 Columns 61 through 78 10 11 12 8 9 10 11 12 9 10 11 12 10 11 12 11 12 12 ans = Columns 1 through 30 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 Columns 31 through 60 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 Columns 61 through 78 11 11 11 11 11 11 12 12 12 12 12 12 12 12 12 12 12 12

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

vec1 = [] vec1 = 1 2 3 4 5 6 7 8 9 vec1 = 1 2 3 4 5 6 7 8 9 2 3 4 5 6 7 8 9 vec1 = 1 2 3 4 5 6 7 8 9 2 3 4 5 6 7 8 9 3 4 5 6 7 8 9 vec1 = 1 2 3 4 5 6 7 8 9 2 3 4 5 6 7 8 9 3 4 5 6 7 8 9 4 5 6 7 8 9 vec1 = Columns 1 through 30 1 2 3 4 5 6 7 8 9 2 3 4 5 6 7 8 9 3 4 5 6 7 8 9 4 5 6 7 8 9 Columns 31 through 35 5 6 7 8 9 vec1 = Columns 1 through 30 1 2 3 4 5 6 7 8 9 2 3 4 5 6 7 8 9 3 4 5 6 7 8 9 4 5 6 7 8 9 Columns 31 through 39 5 6 7 8 9 6 7 8 9 vec1 = Columns 1 through 30 1 2 3 4 5 6 7 8 9 2 3 4 5 6 7 8 9 3 4 5 6 7 8 9 4 5 6 7 8 9 Columns 31 through 42 5 6 7 8 9 6 7 8 9 7 8 9 vec1 = Columns 1 through 30 1 2 3 4 5 6 7 8 9 2 3 4 5 6 7 8 9 3 4 5 6 7 8 9 4 5 6 7 8 9 Columns 31 through 44 5 6 7 8 9 6 7 8 9 7 8 9 8 9 vec1 = Columns 1 through 30 1 2 3 4 5 6 7 8 9 2 3 4 5 6 7 8 9 3 4 5 6 7 8 9 4 5 6 7 8 9 Columns 31 through 45 5 6 7 8 9 6 7 8 9 7 8 9 8 9 9 ans = Columns 1 through 30 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 Columns 31 through 45 8 8 8 8 8 8 9 9 9 9 9 9 9 9 9

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

vec1 = [] vec1 = 1 2 3 4 5 6 7 vec1 = 1 2 3 4 5 6 7 2 3 4 5 6 7 vec1 = 1 2 3 4 5 6 7 2 3 4 5 6 7 3 4 5 6 7 vec1 = 1 2 3 4 5 6 7 2 3 4 5 6 7 3 4 5 6 7 4 5 6 7 vec1 = 1 2 3 4 5 6 7 2 3 4 5 6 7 3 4 5 6 7 4 5 6 7 5 6 7 vec1 = 1 2 3 4 5 6 7 2 3 4 5 6 7 3 4 5 6 7 4 5 6 7 5 6 7 6 7 vec1 = 1 2 3 4 5 6 7 2 3 4 5 6 7 3 4 5 6 7 4 5 6 7 5 6 7 6 7 7 ans = 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

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

vec1 = [] vec1 = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 vec1 = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 2 3 4 5 6 7 8 9 10 11 12 13 14 15 vec1 = Columns 1 through 30 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 2 3 4 5 6 7 8 9 10 11 12 13 14 15 3 Columns 31 through 42 4 5 6 7 8 9 10 11 12 13 14 15 vec1 = Columns 1 through 30 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 2 3 4 5 6 7 8 9 10 11 12 13 14 15 3 Columns 31 through 54 4 5 6 7 8 9 10 11 12 13 14 15 4 5 6 7 8 9 10 11 12 13 14 15 vec1 = Columns 1 through 30 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 2 3 4 5 6 7 8 9 10 11 12 13 14 15 3 Columns 31 through 60 4 5 6 7 8 9 10 11 12 13 14 15 4 5 6 7 8 9 10 11 12 13 14 15 5 6 7 8 9 10 Columns 61 through 65 11 12 13 14 15 vec1 = Columns 1 through 30 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 2 3 4 5 6 7 8 9 10 11 12 13 14 15 3 Columns 31 through 60 4 5 6 7 8 9 10 11 12 13 14 15 4 5 6 7 8 9 10 11 12 13 14 15 5 6 7 8 9 10 Columns 61 through 75 11 12 13 14 15 6 7 8 9 10 11 12 13 14 15 vec1 = Columns 1 through 30 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 2 3 4 5 6 7 8 9 10 11 12 13 14 15 3 Columns 31 through 60 4 5 6 7 8 9 10 11 12 13 14 15 4 5 6 7 8 9 10 11 12 13 14 15 5 6 7 8 9 10 Columns 61 through 84 11 12 13 14 15 6 7 8 9 10 11 12 13 14 15 7 8 9 10 11 12 13 14 15 vec1 = Columns 1 through 30 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 2 3 4 5 6 7 8 9 10 11 12 13 14 15 3 Columns 31 through 60 4 5 6 7 8 9 10 11 12 13 14 15 4 5 6 7 8 9 10 11 12 13 14 15 5 6 7 8 9 10 Columns 61 through 90 11 12 13 14 15 6 7 8 9 10 11 12 13 14 15 7 8 9 10 11 12 13 14 15 8 9 10 11 12 13 Columns 91 through 92 14 15 vec1 = Columns 1 through 30 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 2 3 4 5 6 7 8 9 10 11 12 13 14 15 3 Columns 31 through 60 4 5 6 7 8 9 10 11 12 13 14 15 4 5 6 7 8 9 10 11 12 13 14 15 5 6 7 8 9 10 Columns 61 through 90 11 12 13 14 15 6 7 8 9 10 11 12 13 14 15 7 8 9 10 11 12 13 14 15 8 9 10 11 12 13 Columns 91 through 99 14 15 9 10 11 12 13 14 15 vec1 = Columns 1 through 30 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 2 3 4 5 6 7 8 9 10 11 12 13 14 15 3 Columns 31 through 60 4 5 6 7 8 9 10 11 12 13 14 15 4 5 6 7 8 9 10 11 12 13 14 15 5 6 7 8 9 10 Columns 61 through 90 11 12 13 14 15 6 7 8 9 10 11 12 13 14 15 7 8 9 10 11 12 13 14 15 8 9 10 11 12 13 Columns 91 through 105 14 15 9 10 11 12 13 14 15 10 11 12 13 14 15 vec1 = Columns 1 through 30 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 2 3 4 5 6 7 8 9 10 11 12 13 14 15 3 Columns 31 through 60 4 5 6 7 8 9 10 11 12 13 14 15 4 5 6 7 8 9 10 11 12 13 14 15 5 6 7 8 9 10 Columns 61 through 90 11 12 13 14 15 6 7 8 9 10 11 12 13 14 15 7 8 9 10 11 12 13 14 15 8 9 10 11 12 13 Columns 91 through 110 14 15 9 10 11 12 13 14 15 10 11 12 13 14 15 11 12 13 14 15 vec1 = Columns 1 through 30 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 2 3 4 5 6 7 8 9 10 11 12 13 14 15 3 Columns 31 through 60 4 5 6 7 8 9 10 11 12 13 14 15 4 5 6 7 8 9 10 11 12 13 14 15 5 6 7 8 9 10 Columns 61 through 90 11 12 13 14 15 6 7 8 9 10 11 12 13 14 15 7 8 9 10 11 12 13 14 15 8 9 10 11 12 13 Columns 91 through 114 14 15 9 10 11 12 13 14 15 10 11 12 13 14 15 11 12 13 14 15 12 13 14 15 vec1 = Columns 1 through 30 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 2 3 4 5 6 7 8 9 10 11 12 13 14 15 3 Columns 31 through 60 4 5 6 7 8 9 10 11 12 13 14 15 4 5 6 7 8 9 10 11 12 13 14 15 5 6 7 8 9 10 Columns 61 through 90 11 12 13 14 15 6 7 8 9 10 11 12 13 14 15 7 8 9 10 11 12 13 14 15 8 9 10 11 12 13 Columns 91 through 117 14 15 9 10 11 12 13 14 15 10 11 12 13 14 15 11 12 13 14 15 12 13 14 15 13 14 15 vec1 = Columns 1 through 30 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 2 3 4 5 6 7 8 9 10 11 12 13 14 15 3 Columns 31 through 60 4 5 6 7 8 9 10 11 12 13 14 15 4 5 6 7 8 9 10 11 12 13 14 15 5 6 7 8 9 10 Columns 61 through 90 11 12 13 14 15 6 7 8 9 10 11 12 13 14 15 7 8 9 10 11 12 13 14 15 8 9 10 11 12 13 Columns 91 through 119 14 15 9 10 11 12 13 14 15 10 11 12 13 14 15 11 12 13 14 15 12 13 14 15 13 14 15 14 15 vec1 = Columns 1 through 30 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 2 3 4 5 6 7 8 9 10 11 12 13 14 15 3 Columns 31 through 60 4 5 6 7 8 9 10 11 12 13 14 15 4 5 6 7 8 9 10 11 12 13 14 15 5 6 7 8 9 10 Columns 61 through 90 11 12 13 14 15 6 7 8 9 10 11 12 13 14 15 7 8 9 10 11 12 13 14 15 8 9 10 11 12 13 Columns 91 through 120 14 15 9 10 11 12 13 14 15 10 11 12 13 14 15 11 12 13 14 15 12 13 14 15 13 14 15 14 15 15 ans = Columns 1 through 30 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 Columns 31 through 60 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 Columns 61 through 90 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 Columns 91 through 120 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