Cody

# Problem 611. surrounded matrix

Solution 1898886

Submitted on 13 Aug 2019 by Yuumi Ozaki
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; y_correct = ones(3); assert(isequal(surrounded(x),y_correct))

r = 1 c = 1 one = 1 1 1 1 1 1 1 1 1 one = 1 1 1 1 1 1 1 1 1 B = 1 1 1 1 1 1 1 1 1

2   Pass
x = [3 3 3;3 3 3]; y_correct = [1 1 1 1 1;1 3 3 3 1; 1 3 3 3 1; 1 1 1 1 1]; assert(isequal(surrounded(x),y_correct))

r = 2 c = 3 one = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 one = 1 1 1 1 1 1 3 1 1 1 1 1 1 1 1 1 1 1 1 1 one = 1 1 1 1 1 1 3 3 1 1 1 1 1 1 1 1 1 1 1 1 one = 1 1 1 1 1 1 3 3 3 1 1 1 1 1 1 1 1 1 1 1 one = 1 1 1 1 1 1 3 3 3 1 1 3 1 1 1 1 1 1 1 1 one = 1 1 1 1 1 1 3 3 3 1 1 3 3 1 1 1 1 1 1 1 one = 1 1 1 1 1 1 3 3 3 1 1 3 3 3 1 1 1 1 1 1 B = 1 1 1 1 1 1 3 3 3 1 1 3 3 3 1 1 1 1 1 1

3   Pass
x = ones(3,4); y_correct = ones(5,6); assert(isequal(surrounded(x),y_correct))

r = 3 c = 4 one = 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 1 one = 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 1 one = 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 1 one = 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 1 one = 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 1 one = 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 1 one = 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 1 one = 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 1 one = 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 1 one = 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 1 one = 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 1 one = 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 1 one = 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 1 B = 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 1

4   Pass
x = [0]; y_correct = ones(3); y_correct(2,2) = 0; assert(isequal(surrounded(x),y_correct))

r = 1 c = 1 one = 1 1 1 1 1 1 1 1 1 one = 1 1 1 1 0 1 1 1 1 B = 1 1 1 1 0 1 1 1 1

5   Pass
x = reshape(1:9,[3,3]); y_correct = [1 1 1 1 1; 1 1 2 3 1; ... 1 4 5 6 1; 1 7 8 9 1; 1 1 1 1 1]'; assert(isequal(surrounded(x),y_correct))

r = 3 c = 3 one = 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 one = 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 one = 1 1 1 1 1 1 1 4 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 one = 1 1 1 1 1 1 1 4 7 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 one = 1 1 1 1 1 1 1 4 7 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 one = 1 1 1 1 1 1 1 4 7 1 1 2 5 1 1 1 1 1 1 1 1 1 1 1 1 one = 1 1 1 1 1 1 1 4 7 1 1 2 5 8 1 1 1 1 1 1 1 1 1 1 1 one = 1 1 1 1 1 1 1 4 7 1 1 2 5 8 1 1 3 1 1 1 1 1 1 1 1 one = 1 1 1 1 1 1 1 4 7 1 1 2 5 8 1 1 3 6 1 1 1 1 1 1 1 one = 1 1 1 1 1 1 1 4 7 1 1 2 5 8 1 1 3 6 9 1 1 1 1 1 1 B = 1 1 1 1 1 1 1 4 7 1 1 2 5 8 1 1 3 6 9 1 1 1 1 1 1