Cody

# Problem 43656. Tent matrix

Solution 1054558

Submitted on 16 Nov 2016 by Kensuke Fujita
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
n = 1; y_correct = 1; assert(isequal(surround(n),y_correct))

y = 0 k = 1 y = 1 y = 1 y = 1 y = 1

2   Pass
n=3 y_correct = [1 2 1 2 3 2 1 2 1]; assert(isequal(surround(n),y_correct))

n = 3 y = 0 0 0 0 0 0 0 0 0 k = 2 y = 1 0 0 0 0 0 0 0 0 y = 1 0 1 0 0 0 0 0 0 y = 1 0 1 0 0 0 1 0 0 y = 1 0 1 0 0 0 1 0 1 y = 1 2 1 0 0 0 1 0 1 y = 1 2 1 0 0 0 1 0 1 y = 1 2 1 0 0 0 1 2 1 y = 1 2 1 0 0 0 1 2 1 y = 1 2 1 2 0 0 1 2 1 y = 1 2 1 2 0 2 1 2 1 y = 1 2 1 2 0 2 1 2 1 y = 1 2 1 2 0 2 1 2 1 y = 1 2 1 2 3 2 1 2 1 y = 1 2 1 2 3 2 1 2 1 y = 1 2 1 2 3 2 1 2 1 y = 1 2 1 2 3 2 1 2 1

3   Pass
n=7 y_correct = [1 2 3 4 3 2 1 2 3 4 5 4 3 2 3 4 5 6 5 4 3 4 5 6 7 6 5 4 3 4 5 6 5 4 3 2 3 4 5 4 3 2 1 2 3 4 3 2 1]; assert(isequal(surround(n),y_correct))

n = 7 y = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 k = 4 y = 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 y = 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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