Cody

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

Solution 1928873

Submitted on 10 Sep 2019
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 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))

l = [] l = 1 l = 1 1 l = 1 1 1 l = 1 1 1 1 l = 1 1 1 1 0 l = 1 1 1 1 0 0 l = 1 1 1 1 0 0 0 l = 1 1 1 1 0 0 0 0 l = 1 1 1 1 0 0 0 0 0 l = 1 1 1 1 0 0 0 0 0 1 l = 1 1 1 1 0 0 0 0 0 1 1 l = 1 1 1 1 0 0 0 0 0 1 1 1 l = 1 1 1 1 0 0 0 0 0 1 1 1 1 l = 1 1 1 1 0 0 0 0 0 1 1 1 1 0 l = 1 1 1 1 0 0 0 0 0 1 1 1 1 0 0 l = 1 1 1 1 0 0 0 0 0 1 1 1 1 0 0 0

Assertion failed.

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

l = [] l = 0 l = 0 1 l = 0 1 1 l = 0 1 1 1 l = 0 1 1 1 1 l = 0 1 1 1 1 1 l = 0 1 1 1 1 1 1 l = 0 1 1 1 1 1 1 0 l = 0 1 1 1 1 1 1 0 0 l = 0 1 1 1 1 1 1 0 0 1 l = 0 1 1 1 1 1 1 0 0 1 1 l = 0 1 1 1 1 1 1 0 0 1 1 0 l = 0 1 1 1 1 1 1 0 0 1 1 0 0 l = 0 1 1 1 1 1 1 0 0 1 1 0 0 0 l = 0 1 1 1 1 1 1 0 0 1 1 0 0 0 0 l = 0 1 1 1 1 1 1 0 0 1 1 0 0 0 0 0 l = 0 1 1 1 1 1 1 0 0 1 1 0 0 0 0 0 0 l = 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 1 1 1 1 0 0 0 0 0 0 0 0 l = 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 l = 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

Assertion failed.

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

l = [] l = 1 l = 1 1 l = 1 1 1 l = 1 1 1 1 l = 1 1 1 1 1 l = 1 1 1 1 1 1 l = 1 1 1 1 1 1 1 l = 1 1 1 1 1 1 1 1 l = 1 1 1 1 1 1 1 1 1 l = 1 1 1 1 1 1 1 1 1 1 l = 1 1 1 1 1 1 1 1 1 1 1 l = 1 1 1 1 1 1 1 1 1 1 1 1 l = 1 1 1 1 1 1 1 1 1 1 1 1 1 l = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 l = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 l = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 l = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 l = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 l = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 l = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 l = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 l = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 l = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 l = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 l = 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 l = 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 l = 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 l = 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 l = 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 l = Columns 1 through 29 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 30 1 l = Columns 1 through 29 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 30 through 31 1 1 l = Columns 1 through 29 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 30 through 32 1 1 1 l = Columns 1 through 29 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 30 through 33 1 1 1 1 l = Columns 1 through 29 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 30 through 34 1 1 1 1 1 l = Columns 1 through 29 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 30 through 35 1 1 1 1 1 1 l = Columns 1 through 29 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 30 through 36 1 1 1 1 1 1 1 l = Columns 1 through 29 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 30 through 37 1 1 1 1 1 1 1 1 l = Columns 1 through 29 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 30 through 38 1 1 1 1 1 1 1 1 1 l = Columns 1 through 29 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 30 through 39 1 1 1 1 1 1 1 1 1 1 l = Columns 1 through 29 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 30 through 40 1 1 1 1 1 1 1 1 1 1 1 l = Columns 1 through 29 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 30 through 41 1 1 1 1 1 1 1 1 1 1 1 1 l = Columns 1 through 29 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 30 through 42 1 1 1 1 1 1 1 1 1 1 1 1 1 l = Columns 1 through 29 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 30 through 43 1 1 1 1 1 1 1 1 1 1 1 1 1 1 l = Columns 1 through 29 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 30 through 44 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 l = Columns 1 through 29 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 30 through 45 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 l = Columns 1 through 29 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 30 through 46 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 l = Columns 1 through 29 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 30 through 47 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 l = Columns 1 through 29 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 30 through 48 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 l = Columns 1 through 29 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 30 through 49 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 l = Columns 1 through 29 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 30 through 50 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 l = Columns 1 through 29 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 30 through 51 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 l = Columns 1 through 29 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 30 through 52 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 l = Columns 1 through 29 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

Assertion failed.