Cody

Solution 1574906

Submitted on 3 Jul 2018 by Jamal Nasir
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 t = 3 t = 3 j = 2 t = 1 t = 0 t = 9 t = 9 j = 2 t = 4 t = 4 j = 2 t = 4 j = 3 t = 4 j = 4 t = 5 t = 1 t = 2 t = 2 j = 2

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

r = 1 t = 1 j = 2 t = 1 j = 3 t = 1 j = 4 t = 1 j = 5 t = 1 j = 6 t = 1 j = 7 t = 1 j = 8 t = 1 j = 9 t = 1 j = 10 t = 1 j = 11 t = 1 j = 12 t = 1 j = 13 t = 1 j = 14 t = 1 j = 15 t = 1 j = 16 t = 1 j = 17 t = 1 j = 18 t = 1 j = 19 t = 1 j = 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))

r = 1 t = 1 j = 2 t = 1 j = 3 t = 2 t = 2 j = 2 t = 3 t = 4 t = 4 j = 2 t = 5 t = 5 j = 2 t = 5 j = 3

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

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

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

r = 1 t = -17 t = -17 j = 2 t = -17 j = 3 t = -17 j = 4 t = -17 j = 5 t = -17 j = 6 t = -17 j = 7 t = -17 j = 8 t = -17 j = 9 t = -17 j = 10 t = -17 j = 11 t = -17 j = 12 t = -17 j = 13 t = -17 j = 14 t = -17 j = 15 t = -17 j = 16 t = -17 j = 17 t = -17 j = 18 t = -17 j = 19 t = -17 j = 20 t = -17 j = 21 t = -17 j = 22 t = -17 j = 23 t = -17 j = 24 t = -17 j = 25 t = -17 j = 26 t = -17 j = 27 t = -17 j = 28 t = -17 j = 29 t = -17 j = 30 t = -17 j = 31 t = -17 j = 32 t = -17 j = 33 t = -17 j = 34 t = -17 j = 35 t = -17 j = 36 t = -17 j = 37 t = -17 j = 38 t = -17 j = 39 t = -17 j = 40 t = -17 j = 41 t = -17 j = 42 t = -17 j = 43 t = -17 j = 44 t = -17 j = 45 t = -17 j = 46 t = -17 j = 47 t = -17 j = 48 t = -17 j = 49 t = -17 j = 50 t = -17 j = 51 t = -17 j = 52 t = -17 j = 53 t = -17 j = 54 t = -17 j = 55 t = -17 j = 56 t = -17 j = 57 t = -17 j = 58 t = -17 j = 59 t = -17 j = 60 t = -17 j = 61 t = -17 j = 62 t = -17 j = 63 t = -17 j = 64 t = -17 j = 65 t = -17 j = 66 t = -17 j = 67 t = -17 j = 68 t = -17 j = 69 t = -17 j = 70 t = -17 j = 71 t = -17 j = 72 t = -17 j = 73 t = -17 j = 74 t = -17 j = 75 t = -17 j = 76 t = -17 j = 77 t = -17 j = 78 t = -17 j = 79 t = -17 j = 80 t = -17 j = 81 t = -17 j = 82 t = -17 j = 83 t = -17 j = 84 t = -17 j = 85 t = -17 j = 86 t = -17 j = 87 t = -17 j = 88 t = -17 j = 89 t = -17 j = 90 t = -17 j = 91 t = -17 j = 92 t = -17 j = 93 t = -17 j = 94 t = -17 j = 95 t = -17 j = 96 t = -17 j = 97 t = -17 j = 98 t = -17 j = 99 t = -17 j = 100