Cody

Solution 615072

Submitted on 9 Apr 2015 by Jonathan Campelli
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 = [5 3 3 1 0 9 9 4 4 4 4 5 1 2 2]; r_correct = [1 1 2 1 1 1 2 1 2 3 4 1 1 1 2]; assert(isequal(run_length(x),r_correct))

d = 0 1 0 0 0 1 0 1 1 1 0 0 0 1 ans = 1 ans = 1 1 ans = 1 1 2 ans = 1 1 2 1 ans = 1 1 2 1 1 ans = 1 1 2 1 1 1 ans = 1 1 2 1 1 1 2 ans = 1 1 2 1 1 1 2 1 ans = 1 1 2 1 1 1 2 1 2 ans = 1 1 2 1 1 1 2 1 2 3 ans = 1 1 2 1 1 1 2 1 2 3 4 ans = 1 1 2 1 1 1 2 1 2 3 4 1 ans = 1 1 2 1 1 1 2 1 2 3 4 1 1 ans = 1 1 2 1 1 1 2 1 2 3 4 1 1 1 ans = 1 1 2 1 1 1 2 1 2 3 4 1 1 1 2

2   Pass
%% x = ones(1,20); r_correct = 1:20; assert(isequal(run_length(x),r_correct))

d = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ans = 1 ans = 1 2 ans = 1 2 3 ans = 1 2 3 4 ans = 1 2 3 4 5 ans = 1 2 3 4 5 6 ans = 1 2 3 4 5 6 7 ans = 1 2 3 4 5 6 7 8 ans = 1 2 3 4 5 6 7 8 9 ans = 1 2 3 4 5 6 7 8 9 10 ans = 1 2 3 4 5 6 7 8 9 10 11 ans = 1 2 3 4 5 6 7 8 9 10 11 12 ans = 1 2 3 4 5 6 7 8 9 10 11 12 13 ans = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ans = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ans = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ans = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ans = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 ans = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ans = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

3   Pass
%% x = [1 1 1 2 2 3 4 4 5 5 5]; r_correct = [1 2 3 1 2 1 1 2 1 2 3]; assert(isequal(run_length(x),r_correct))

d = 1 1 0 1 0 0 1 0 1 1 ans = 1 ans = 1 2 ans = 1 2 3 ans = 1 2 3 1 ans = 1 2 3 1 2 ans = 1 2 3 1 2 1 ans = 1 2 3 1 2 1 1 ans = 1 2 3 1 2 1 1 2 ans = 1 2 3 1 2 1 1 2 1 ans = 1 2 3 1 2 1 1 2 1 2 ans = 1 2 3 1 2 1 1 2 1 2 3

4   Pass
%% x = 1:40; r_correct = ones(size(x)); assert(isequal(run_length(x),r_correct))

d = Columns 1 through 30 0 0 0 0 0 0 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 31 through 39 0 0 0 0 0 0 0 0 0 ans = 1 ans = 1 1 ans = 1 1 1 ans = 1 1 1 1 ans = 1 1 1 1 1 ans = 1 1 1 1 1 1 ans = 1 1 1 1 1 1 1 ans = 1 1 1 1 1 1 1 1 ans = 1 1 1 1 1 1 1 1 1 ans = 1 1 1 1 1 1 1 1 1 1 ans = 1 1 1 1 1 1 1 1 1 1 1 ans = 1 1 1 1 1 1 1 1 1 1 1 1 ans = 1 1 1 1 1 1 1 1 1 1 1 1 1 ans = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ans = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ans = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ans = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ans = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ans = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ans = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ans = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ans = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ans = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ans = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ans = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ans = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ans = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ans = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ans = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ans = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ans = Columns 1 through 30 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Column 31 1 ans = Columns 1 through 30 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 31 through 32 1 1 ans = Columns 1 through 30 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 31 through 33 1 1 1 ans = Columns 1 through 30 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 31 through 34 1 1 1 1 ans = Columns 1 through 30 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 31 through 35 1 1 1 1 1 ans = Columns 1 through 30 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 31 through 36 1 1 1 1 1 1 ans = Columns 1 through 30 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 31 through 37 1 1 1 1 1 1 1 ans = Columns 1 through 30 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 31 through 38 1 1 1 1 1 1 1 1 ans = Columns 1 through 30 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 31 through 39 1 1 1 1 1 1 1 1 1 ans = Columns 1 through 30 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 31 through 40 1 1 1 1 1 1 1 1 1 1

5   Pass
%% x = [-34 -17*ones(1,100)]; r_correct = [1 1:100]; assert(isequal(run_length(x),r_correct))

d = Columns 1 through 30 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 31 through 60 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 61 through 90 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 91 through 100 1 1 1 1 1 1 1 1 1 1 ans = 1 ans = 1 1 ans = 1 1 2 ans = 1 1 2 3 ans = 1 1 2 3 4 ans = 1 1 2 3 4 5 ans = 1 1 2 3 4 5 6 ans = 1 1 2 3 4 5 6 7 ans = 1 1 2 3 4 5 6 7 8 ans = 1 1 2 3 4 5 6 7 8 9 ans = 1 1 2 3 4 5 6 7 8 9 10 ans = 1 1 2 3 4 5 6 7 8 9 10 11 ans = 1 1 2 3 4 5 6 7 8 9 10 11 12 ans = 1 1 2 3 4 5 6 7 8 9 10 11 12 13 ans = 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ans = 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ans = 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ans = 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ans = 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 ans = 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ans = 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ans = 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 ans = 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 ans = 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 ans = 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 ans = 1 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 ans = 1 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 ans = 1 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 ans = 1 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 ans = 1 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 ans = Columns 1 through 30 1 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 Column 31 30 ans = Columns 1 through 30 1 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 31 through 32 30 31 ans = Columns 1 through 30 1 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 31 through 33 30 31 32 ans = Columns 1 through 30 1 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 31 through 34 30 31 32 33 ans = Columns 1 through 30 1 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 31 through 35 30 31 32 33 34 ans = Columns 1 through 30 1 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 31 through 36 30 31 32 33 34 35 ans = Columns 1 through 30 1 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 31 through 37 30 31 32 33 34 35 36 ans = Columns 1 through 30 1 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 31 through 38 30 31 32 33 34 35 36 37 ans = Columns 1 through 30 1 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 31 through 39 30 31 32 33 34 35 36 37 38 ans = Columns 1 through 30 1 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 31 through 40 30 31 32 33 34 35 36 37 38 39 ans = Columns 1 through 30 1 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 31 through 41 30 31 32 33 34 35 36 37 38 39 40 ans = Columns 1 through 30 1 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 31 through 42 30 31 32 33 34 35 36 37 38 39 40 41 ans = Columns 1 through 30 1 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 31 through 43 30 31 32 33 34 35 36 37 38 39 40 41 42 ans = Columns 1 through 30 1 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 31 through 44 30 31 32 33 34 35 36 37 38 39 40 41 42 43 ans = Columns 1 through 30 1 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 31 through 45 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 ans = Columns 1 through 30 1 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 31 through 46 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 ans = Columns 1 through 30 1 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 31 through 47 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 ans = Columns 1 through 30 1 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 31 through 48 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 ans = Columns 1 through 30 1 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 31 through 49 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 ans = Columns 1 through 30 1 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 31 through 50 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 ans = Columns 1 through 30 1 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 31 through 51 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 4...