Cody

# Problem 55. Counting Sequence

Solution 1919350

Submitted on 2 Sep 2019 by Tetsuji Tsuda
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 5 2 1 1 1 1 3]; correct = [2 5 1 2 4 1 1 3]; assert(isequal(correct, CountSeq(x)));

a = [] l = 8 p = 5 c = 1 va = [] ca = [] c = 2 p = 5 va = 5 ca = 2 c = 1 p = 2 va = 5 2 ca = 2 1 c = 1 p = 1 c = 2 p = 1 c = 3 p = 1 c = 4 p = 1 va = 5 2 1 ca = 2 1 4 c = 1 p = 3 va = 5 2 1 3 ca = 2 1 4 1 a = 2 5 a = 2 5 1 2 a = 2 5 1 2 4 1 a = 2 5 1 2 4 1 1 3 y = 2 5 1 2 4 1 1 3

2   Pass
x = [9]; correct = [1 9]; assert(isequal(correct, CountSeq(x)));

a = [] l = 1 y = 1 9

3   Pass
x = ones(1,9); correct = [9 1]; assert(isequal(correct, CountSeq(x)));

a = [] l = 9 p = 1 c = 1 va = [] ca = [] c = 2 p = 1 c = 3 p = 1 c = 4 p = 1 c = 5 p = 1 c = 6 p = 1 c = 7 p = 1 c = 8 p = 1 c = 9 va = 1 ca = 9 p = 1 a = 9 1 y = 9 1

4   Pass
x = 1:9; correct = [1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9]; assert(isequal(correct, CountSeq(x)));

a = [] l = 9 p = 1 c = 1 va = [] ca = [] va = 1 ca = 1 c = 1 p = 2 va = 1 2 ca = 1 1 c = 1 p = 3 va = 1 2 3 ca = 1 1 1 c = 1 p = 4 va = 1 2 3 4 ca = 1 1 1 1 c = 1 p = 5 va = 1 2 3 4 5 ca = 1 1 1 1 1 c = 1 p = 6 va = 1 2 3 4 5 6 ca = 1 1 1 1 1 1 c = 1 p = 7 va = 1 2 3 4 5 6 7 ca = 1 1 1 1 1 1 1 c = 1 p = 8 va = 1 2 3 4 5 6 7 8 ca = 1 1 1 1 1 1 1 1 c = 1 p = 9 va = 1 2 3 4 5 6 7 8 9 ca = 1 1 1 1 1 1 1 1 1 a = 1 1 a = 1 1 1 2 a = 1 1 1 2 1 3 a = 1 1 1 2 1 3 1 4 a = 1 1 1 2 1 3 1 4 1 5 a = 1 1 1 2 1 3 1 4 1 5 1 6 a = 1 1 1 2 1 3 1 4 1 5 1 6 1 7 a = 1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 a = 1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 y = 1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9

5   Pass
x = [1 2 2 1]; correct = [1 1 2 2 1 1]; assert(isequal(correct, CountSeq(x)));

a = [] l = 4 p = 1 c = 1 va = [] ca = [] va = 1 ca = 1 c = 1 p = 2 c = 2 p = 2 va = 1 2 ca = 1 2 c = 1 p = 1 va = 1 2 1 ca = 1 2 1 a = 1 1 a = 1 1 2 2 a = 1 1 2 2 1 1 y = 1 1 2 2 1 1