Cody

# Problem 2651. Find the same and successive values in a vector

Solution 1693484

Submitted on 16 Dec 2018
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   Fail
x = [1,0,0,1,1,1,1,0,1,1,1,0,0,0,1]; y = [ 2 4 9 12 3 7 11 14 0 1 1 0]; assert(isequal(successive_value(x),y))

y = 2 3 0 y = 2 4 3 5 0 1 y = 2 4 4 3 5 6 0 1 1 y = 2 4 4 4 3 5 6 7 0 1 1 1 y = 2 4 4 4 9 3 5 6 7 10 0 1 1 1 1 y = 2 4 4 4 9 9 3 5 6 7 10 11 0 1 1 1 1 1 y = 2 4 4 4 9 9 12 3 5 6 7 10 11 13 0 1 1 1 1 1 0 y = 2 4 4 4 9 9 12 12 3 5 6 7 10 11 13 14 0 1 1 1 1 1 0 0

Assertion failed.

2   Fail
x = [1,0,0,1,1,1,1,0,2,2,2,0,0,0,2345,2345,2345,2345,2345]; y = [2 4 9 12 15 3 7 11 14 19 0 1 2 0 2345 ]; assert(isequal(successive_value(x),y))

y = 2 3 0 y = 2 4 3 5 0 1 y = 2 4 4 3 5 6 0 1 1 y = 2 4 4 4 3 5 6 7 0 1 1 1 y = 2 4 4 4 9 3 5 6 7 10 0 1 1 1 2 y = 2 4 4 4 9 9 3 5 6 7 10 11 0 1 1 1 2 2 y = 2 4 4 4 9 9 12 3 5 6 7 10 11 13 0 1 1 1 2 2 0 y = 2 4 4 4 9 9 12 12 3 5 6 7 10 11 13 14 0 1 1 1 2 2 0 0 y = 2 4 4 4 9 9 12 12 15 3 5 6 7 10 11 13 14 16 0 1 1 1 2 2 0 0 2345 y = 2 4 4 4 9 9 12 12 15 15 3 5 6 7 10 11 13 14 16 17 0 1 1 1 2 2 0 0 2345 2345 y = 2 4 4 4 9 9 12 12 15 15 15 3 5 6 7 10 11 13 14 16 17 19 0 1 1 1 2 2 0 0 2345 2345 2345 y = 2 4 4 4 9 9 12 12 15 15 15 15 3 5 6 7 10 11 13 14 16 17 19 18 0 1 1 1 2 2 0 0 2345 2345 2345 2345

Assertion failed.

3   Fail
x = ones(1,10); y = [1;10;1]; assert(isequal(successive_value(x),y))

y = 1 2 1 y = 1 1 2 3 1 1 y = 1 1 1 2 3 4 1 1 1 y = 1 1 1 1 2 3 4 5 1 1 1 1 y = 1 1 1 1 1 2 3 4 5 6 1 1 1 1 1 y = 1 1 1 1 1 1 2 3 4 5 6 7 1 1 1 1 1 1 y = 1 1 1 1 1 1 1 2 3 4 5 6 7 8 1 1 1 1 1 1 1 y = 1 1 1 1 1 1 1 1 2 3 4 5 6 7 8 10 1 1 1 1 1 1 1 1 y = 1 1 1 1 1 1 1 1 1 2 3 4 5 6 7 8 10 9 1 1 1 1 1 1 1 1 1

Assertion failed.

4   Pass
x = 1:20; assert(isempty(successive_value(x)))

5   Pass
x = repmat([1,0],[1,1000]); x = [x,fliplr(x)]; y = [2000;2001;0]; assert(isequal(successive_value(x),y))

y = 2000 2001 0