Cody

# Problem 2153. Replace pattern 0 1 0 and 1 0 1

Solution 1675350

Submitted on 16 Nov 2018 by Athi
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 = [1 0 1 1 0 0 1 0 0 1 1 1 1 0 0 0]; y_correct = [1 1 1 1 0 0 0 0 0 1 1 1 1 0 0 0]; assert(isequal(replace_pattern(x),y_correct))

2   Pass
x = [0 1 1 1 0 1 1 0 0 1 1 0 0 1 0 0 1 0 0 1]; y_correct = [0 1 1 1 1 1 1 0 0 1 1 0 0 0 0 0 0 0 0 1]; assert(isequal(replace_pattern(x),y_correct))

3   Pass
x = [ones(1,10); ones(1,10); zeros(1,10)]; x = x(:)'; y_correct = [ones(1,29) 0]; assert(isequal(replace_pattern(x),y_correct))

4   Pass
x = [1 1 1 0 1 1 1 0 1 1 0 1 1 0 1 1 0 0 1 0 0 1 0 0 0 1]; y_correct = [1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 1]; assert(isequal(replace_pattern(x),y_correct))

5   Pass
x = [ones(1,250) zeros(1,250), ones(1,250) zeros(1,250)]; y_correct = x; x([3,35,67,100,103,201]) = 0; x([257,301,333,404]) = 1; x([505,606,616]) = 0; x(997) = 1; assert(isequal(replace_pattern(x),y_correct))