Cody

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

Solution 2674778

Submitted on 10 Jul 2020 by Sergio Enrique Pinto Castillo
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))

ielem = 1 2 numelem = 3 k = 0 k = 1 a = 0 0 2 k = 2 a = 0 2 2 n = 1 k = 0 k = 1 a = 1 2 2 n = 0 k = 0 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))

ielem = 1 2 3 4 5 numelem = 15 k = 0 k = 1 a = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 k = 2 a = 0 0 0 0 0 0 0 0 0 0 0 0 0 5 5 k = 3 a = 0 0 0 0 0 0 0 0 0 0 0 0 5 5 5 k = 4 a = 0 0 0 0 0 0 0 0 0 0 0 5 5 5 5 k = 5 a = 0 0 0 0 0 0 0 0 0 0 5 5 5 5 5 n = 4 k = 0 k = 1 a = 0 0 0 0 0 0 0 0 0 4 5 5 5 5 5 k = 2 a = 0 0 0 0 0 0 0 0 4 4 5 5 5 5 5 k = 3 a = 0 0 0 0 0 0 0 4 4 4 5 5 5 5 5 k = 4 a = 0 0 0 0 0 0 4 4 4 4 5 5 5 5 5 n = 3 k = 0 k = 1 a = 0 0 0 0 0 3 4 4 4 4 5 5 5 5 5 k = 2 a = 0 0 0 0 3 3 4 4 4 4 5 5 5 5 5 k = 3 a = 0 0 0 3 3 3 4 4 4 4 5 5 5 5 5 n = 2 k = 0 k = 1 a = 0 0 2 3 3 3 4 4 4 4 5 5 5 5 5 k = 2 a = 0 2 2 3 3 3 4 4 4 4 5 5 5 5 5 n = 1 k = 0 k = 1 a = 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 n = 0 k = 0 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))

ielem = 1 2 3 4 5 6 7 8 9 10 numelem = 55 k = 0 k = 1 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 55 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 k = 2 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 55 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 k = 3 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 55 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10 k = 4 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 55 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10 10 k = 5 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 55 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10 10 10 k = 6 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 55 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10 10 10 10 k = 7 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 55 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10 10 10 10 10 k = 8 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 55 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10 10 10 10 10 10 k = 9 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 55 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10 10 10 10 10 10 10 k = 10 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 55 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10 10 10 10 10 10 10 10 n = 9 k = 0 k = 1 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 55 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 9 10 10 10 10 10 10 10 10 10 10 k = 2 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 55 0 0 0 0 0 0 0 0 0 0 0 0 0 0 9 9 10 10 10 10 10 10 10 10 10 10 k = 3 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 55 0 0 0 0 0 0 0 0 0 0 0 0 0 9 9 9 10 10 10 10 10 10 10 10 10 10 k = 4 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 55 0 0 0 0 0 0 0 0 0 0 0 0 9 9 9 9 10 10 10 10 10 10 10 10 10 10 k = 5 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 55 0 0 0 0 0 0 0 0 0 0 0 9 9 9 9 9 10 10 10 10 10 10 10 10 10 10 k = 6 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 55 0 0 0 0 0 0 0 0 0 0 9 9 9 9 9 9 10 10 10 10 10 10 10 10 10 10 k = 7 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 55 0 0 0 0 0 0 0 0 0 9 9 9 9 9 9 9 10 10 10 10 10 10 10 10 10 10 k = 8 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 55 0 0 0 0 0 0 0 0 9 9 9 9 9 9 9 9 10 10 10 10 10 10 10 10 10 10 k = 9 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 55 0 0 0 0 0 0 0 9 9 9 9 9 9 9 9 9 10 10 10 10 10 10 10 10 10 10 n = 8 k = 0 k = 1 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 55 0 0 0 0 0 0 8 9 9 9 9 9 9 9 9 9 10 10 10 10 10 10 10 10 10 10 k = 2 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 55 0 0 0 0 0 8 8 9 9 9 9 9 9 9 9 9 10 10 10 10 10 10 10 10 10 10 k = 3 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 55 0 0 0 0 8 8 8 9 9 9 9 9 9 9 9 9 10 10 10 10 10 10 10 10 10 10 k = 4 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 55 0 0 0 8 8 8 8 9 9 9 9 9 9 9 9 9 10 10 10 10 10 10 10 10 10 10 k = 5 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 55 0 0 8 8 8 8 8 9 9 9 9 9 9 9 9 9 10 10 10 10 10 10 10 10 10 10 k = 6 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

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

ielem = 1 2 3 4 5 6 7 8 9 10 11 12 numelem = 78 k = 0 k = 1 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 58 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 59 through 78 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 12 k = 2 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 58 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 59 through 78 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 12 12 k = 3 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 58 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 59 through 78 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 12 12 12 k = 4 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 58 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 59 through 78 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 12 12 12 12 k = 5 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 58 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 59 through 78 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 12 12 12 12 12 k = 6 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 58 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 59 through 78 0 0 0 0 0 0 0 0 0 0 0 0 0 0 12 12 12 12 12 12 k = 7 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 58 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 59 through 78 0 0 0 0 0 0 0 0 0 0 0 0 0 12 12 12 12 12 12 12 k = 8 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 58 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 59 through 78 0 0 0 0 0 0 0 0 0 0 0 0 12 12 12 12 12 12 12 12 k = 9 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 58 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 59 through 78 0 0 0 0 0 0 0 0 0 0 0 12 12 12 12 12 12 12 12 12 k = 10 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 58 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 59 through 78 0 0 0 0 0 0 0 0 0 0 12 12 12 12 12 12 12 12 12 12 k = 11 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 58 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 59 through 78 0 0 0 0 0 0 0 0 0 12 12 12 12 12 12 12 12 12 12 12 k = 12 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 58 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 59 through 78 0 0 0 0 0 0 0 0 12 12 12 12 12 12 12 12 12 12 12 12 n = 11 k = 0 k = 1 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 58 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 59 through 78 0 0 0 0 0 0 0 11 12 12 12 12 12 12 12 12 12 12 12 12 k = 2 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 58 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 59 through 78 0 0 0 0 0 0 11 11 12 12 12 12 12 12 12 12 12 12 12 12 k = 3 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 58 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 59 through 78 0 0 0 0 0 11 11 11 12 12 12 12 12 12 12 12 12 12 12 12 k = 4 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 58 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 59 through 78 0 0 0 0 11 11 11 11 12 12 12 12 12 12 12 12 12 12 12 12 k = 5 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 58 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 59 through 78 0 0 0 11 11 11 11 11 12 12 12 12 12 12 12 12 12 12 12 12 k = 6 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

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

ielem = 1 2 3 4 5 6 7 8 9 numelem = 45 k = 0 k = 1 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 45 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 9 k = 2 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 45 0 0 0 0 0 0 0 0 0 0 0 0 0 0 9 9 k = 3 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 45 0 0 0 0 0 0 0 0 0 0 0 0 0 9 9 9 k = 4 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 45 0 0 0 0 0 0 0 0 0 0 0 0 9 9 9 9 k = 5 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 45 0 0 0 0 0 0 0 0 0 0 0 9 9 9 9 9 k = 6 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 45 0 0 0 0 0 0 0 0 0 0 9 9 9 9 9 9 k = 7 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 45 0 0 0 0 0 0 0 0 0 9 9 9 9 9 9 9 k = 8 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 45 0 0 0 0 0 0 0 0 9 9 9 9 9 9 9 9 k = 9 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 45 0 0 0 0 0 0 0 9 9 9 9 9 9 9 9 9 n = 8 k = 0 k = 1 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 45 0 0 0 0 0 0 8 9 9 9 9 9 9 9 9 9 k = 2 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 45 0 0 0 0 0 8 8 9 9 9 9 9 9 9 9 9 k = 3 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 45 0 0 0 0 8 8 8 9 9 9 9 9 9 9 9 9 k = 4 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 45 0 0 0 8 8 8 8 9 9 9 9 9 9 9 9 9 k = 5 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 45 0 0 8 8 8 8 8 9 9 9 9 9 9 9 9 9 k = 6 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 45 0 8 8 8 8 8 8 9 9 9 9 9 9 9 9 9 k = 7 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 45 8 8 8 8 8 8 8 9 9 9 9 9 9 9 9 9 k = 8 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8 Columns 30 through 45 8 8 8 8 8 8 8 9 9 9 9 9 9 9 9 9 n = 7 k = 0 k = 1 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 8 Columns 30 through 45 8 8 8 8 8 8 8 9 9 9 9 9 9 9 9 9 k = 2 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 7 8 Columns 30 through 45 8 8 8 8 8 8 8 9 9 9 9 9 9 9 9 9 k = 3 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 7 7 8 Columns 30 through 45 8 8 8 8 8 8 8 9 9 9 9 9 9 9 9 9 k = 4 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 7 7 7 8 Columns 30 through 45 8 8 8 8 8 8 8 9 9 9 9 9 9 9 9 9 k = 5 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 7 7 7 7 8 Columns 30 through 45 8 8 8 8 8 8 8 9 9 9 9 9 9 9 9 9 k = 6 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 7 7 7 7 7 8 Columns 30 through 45 8 8 8 8 8 8 8 9 9 9 9 9 9 9 9 9 k = 7 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 7 7 7 7 7 7 8 Columns 30 through 45 8 8 8 8 8 8 8 9 9 9 9 9 9 9 9 9 n = 6 k = 0 k = 1 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 7 7 7 7 7 7 7 8 Columns 30 through 45 8 8 8 8 8 8 8 9 9 9 9 9 9 9 9 9 k = 2 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 7 7 7 7 7 7 7 8 Columns 30 through 45 8 8 8 8 8 8 8 9 9 9 9 9 9 9 9 9 k = 3 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 7 7 7 7 7 7 7 8 Columns 30 through 45 8 8 8 8 8 8 8 9 9 9 9 9 9 9 9 9 k = 4 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 6 7 7 7 7 7 7 7 8 Columns 30 through 45 8 8 8 8 8 8 8 9 9 9 9 9 9 9 9 9 k = 5 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 6 6 7 7 7 7 7 7 7 ...

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

ielem = 1 2 3 4 5 6 7 numelem = 28 k = 0 k = 1 a = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 k = 2 a = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 7 k = 3 a = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 7 7 k = 4 a = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 7 7 7 k = 5 a = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 7 7 7 7 k = 6 a = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 7 7 7 7 7 k = 7 a = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 7 7 7 7 7 7 n = 6 k = 0 k = 1 a = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 7 7 7 7 7 7 7 k = 2 a = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 7 7 7 7 7 7 7 k = 3 a = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 7 7 7 7 7 7 7 k = 4 a = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 6 7 7 7 7 7 7 7 k = 5 a = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 6 6 7 7 7 7 7 7 7 k = 6 a = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 6 6 6 7 7 7 7 7 7 7 n = 5 k = 0 k = 1 a = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 6 6 6 6 6 6 7 7 7 7 7 7 7 k = 2 a = 0 0 0 0 0 0 0 0 0 0 0 0 0 5 5 6 6 6 6 6 6 7 7 7 7 7 7 7 k = 3 a = 0 0 0 0 0 0 0 0 0 0 0 0 5 5 5 6 6 6 6 6 6 7 7 7 7 7 7 7 k = 4 a = 0 0 0 0 0 0 0 0 0 0 0 5 5 5 5 6 6 6 6 6 6 7 7 7 7 7 7 7 k = 5 a = 0 0 0 0 0 0 0 0 0 0 5 5 5 5 5 6 6 6 6 6 6 7 7 7 7 7 7 7 n = 4 k = 0 k = 1 a = 0 0 0 0 0 0 0 0 0 4 5 5 5 5 5 6 6 6 6 6 6 7 7 7 7 7 7 7 k = 2 a = 0 0 0 0 0 0 0 0 4 4 5 5 5 5 5 6 6 6 6 6 6 7 7 7 7 7 7 7 k = 3 a = 0 0 0 0 0 0 0 4 4 4 5 5 5 5 5 6 6 6 6 6 6 7 7 7 7 7 7 7 k = 4 a = 0 0 0 0 0 0 4 4 4 4 5 5 5 5 5 6 6 6 6 6 6 7 7 7 7 7 7 7 n = 3 k = 0 k = 1 a = 0 0 0 0 0 3 4 4 4 4 5 5 5 5 5 6 6 6 6 6 6 7 7 7 7 7 7 7 k = 2 a = 0 0 0 0 3 3 4 4 4 4 5 5 5 5 5 6 6 6 6 6 6 7 7 7 7 7 7 7 k = 3 a = 0 0 0 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 n = 2 k = 0 k = 1 a = 0 0 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 k = 2 a = 0 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 n = 1 k = 0 k = 1 a = 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 n = 0 k = 0 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))

ielem = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 numelem = 120 k = 0 k = 1 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 58 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 59 through 87 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 88 through 116 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 117 through 120 0 0 0 15 k = 2 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 58 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 59 through 87 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 88 through 116 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 117 through 120 0 0 15 15 k = 3 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 58 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 59 through 87 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 88 through 116 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 117 through 120 0 15 15 15 k = 4 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 58 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 59 through 87 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 88 through 116 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 117 through 120 15 15 15 15 k = 5 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 58 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 59 through 87 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 88 through 116 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 15 Columns 117 through 120 15 15 15 15 k = 6 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 58 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 59 through 87 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 88 through 116 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 15 15 Columns 117 through 120 15 15 15 15 k = 7 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 58 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 59 through 87 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 88 through 116 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 15 15 15 Columns 117 through 120 15 15 15 15 k = 8 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 58 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 59 through 87 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 88 through 116 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 15 15 15 15 Columns 117 through 120 15 15 15 15 k = 9 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 58 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 59 through 87 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 88 through 116 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 15 15 15 15 15 Columns 117 through 120 15 15 15 15 k = 10 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 58 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 59 through 87 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 88 through 116 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 15 15 15 15 15 15 Columns 117 through 120 15 15 15 15 k = 11 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 58 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 59 through 87 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 88 through 116 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 15 15 15 15 15 15 15 Columns 117 through 120 15 15 15 15 k = 12 a = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

### Community Treasure Hunt

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

Start Hunting!