Cody

# Problem 1961. Finding neighbors of [-1:1] in a matrix....

Solution 1230790

Submitted on 13 Jul 2017 by Augusto Mazzei
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 2 1; 5 6 7; 2 3 6]; output = [1 1 1; 1 1 1; 1 1 1] assert(isequal(neighbors(x),output))

output = 1 1 1 1 1 1 1 1 1 output = 0 0 0 0 0 0 0 0 0 d = 4 4 6 -3 -3 -1 output = 0 0 0 0 0 1 0 0 1 d = 1 1 1 -1 1 3 output = 1 1 0 0 0 1 0 0 1 output = 1 1 1 0 0 1 0 0 1 output = 1 1 1 1 1 1 0 0 1 output = 1 1 1 1 1 1 0 0 1 output = 1 1 1 1 1 1 1 1 1

2   Pass
x = [8 8 8; 4 4 4; 1 9 7] output = [1 1 1; 1 1 1; 0 0 0] assert(isequal(neighbors(x),output))

x = 8 8 8 4 4 4 1 9 7 output = 1 1 1 1 1 1 0 0 0 output = 0 0 0 0 0 0 0 0 0 d = -4 -4 -4 -3 5 3 d = 0 0 8 0 0 -2 output = 1 1 0 0 0 0 0 0 0 output = 1 1 1 0 0 0 0 0 0 output = 1 1 1 1 1 0 0 0 0 output = 1 1 1 1 1 1 0 0 0

3   Pass
x = [1 8 5; 4 10 22; 1 66 7] output = [0 0 0; 0 0 0; 0 0 0] assert(isequal(neighbors(x),output))

x = 1 8 5 4 10 22 1 66 7 output = 0 0 0 0 0 0 0 0 0 output = 0 0 0 0 0 0 0 0 0 d = 3 2 17 -3 56 -15 d = 7 6 65 -3 12 -59