Cody

Solution 2389053

Submitted on 27 May 2020 by Ankur Sharma
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))

r = 1 1 r = 1 1 2 1 r = 1 1 2 1 1 r = 1 1 2 1 1 1 r = 1 1 2 1 1 1 2 1 r = 1 1 2 1 1 1 2 1 2 3 4 1 r = 1 1 2 1 1 1 2 1 2 3 4 1 1 r = 1 1 2 1 1 1 2 1 2 3 4 1 1 1

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

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

r = 1 2 3 1 r = 1 2 3 1 2 1 r = 1 2 3 1 2 1 1 r = 1 2 3 1 2 1 1 2 1

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

r = 1 1 r = 1 1 1 r = 1 1 1 1 r = 1 1 1 1 1 r = 1 1 1 1 1 1 r = 1 1 1 1 1 1 1 r = 1 1 1 1 1 1 1 1 r = 1 1 1 1 1 1 1 1 1 r = 1 1 1 1 1 1 1 1 1 1 r = 1 1 1 1 1 1 1 1 1 1 1 r = 1 1 1 1 1 1 1 1 1 1 1 1 r = 1 1 1 1 1 1 1 1 1 1 1 1 1 r = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 r = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 r = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 r = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 r = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 r = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 r = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 r = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 r = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 r = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 r = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 r = 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 r = 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 r = 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 r = 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 r = 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 r = 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 r = 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 r = 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 r = 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 r = 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 r = 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 r = 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 r = 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 r = 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 r = 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 r = 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))

r = 1 1