Cody

# Problem 18. Bullseye Matrix

Solution 1401906

Submitted on 2 Jan 2018 by Bailey Horton
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 = 5; a = [3 3 3 3 3; 3 2 2 2 3; 3 2 1 2 3; 3 2 2 2 3; 3 3 3 3 3]; assert(isequal(bullseye(n),a));

centralindex = 3 a = 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 indices = 1 1 horizontal = 2 vertical = 2 determinant = 2 a = 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 indices = 1 2 horizontal = 1 vertical = 2 determinant = 2 a = 3 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 indices = 1 3 horizontal = 0 vertical = 2 determinant = 2 a = 3 3 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 indices = 1 4 horizontal = 1 vertical = 2 determinant = 2 a = 3 3 3 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 indices = 1 5 horizontal = 2 vertical = 2 determinant = 2 a = 3 3 3 3 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 indices = 2 1 horizontal = 2 vertical = 1 determinant = 2 a = 3 3 3 3 3 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 indices = 2 2 horizontal = 1 vertical = 1 determinant = 1 a = 3 3 3 3 3 3 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 indices = 2 3 horizontal = 0 vertical = 1 determinant = 1 a = 3 3 3 3 3 3 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 indices = 2 4 horizontal = 1 vertical = 1 determinant = 1 a = 3 3 3 3 3 3 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 indices = 2 5 horizontal = 2 vertical = 1 determinant = 2 a = 3 3 3 3 3 3 2 2 2 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 indices = 3 1 horizontal = 2 vertical = 0 determinant = 2 a = 3 3 3 3 3 3 2 2 2 3 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 indices = 3 2 horizontal = 1 vertical = 0 determinant = 1 a = 3 3 3 3 3 3 2 2 2 3 3 2 0 0 0 0 0 0 0 0 0 0 0 0 0 indices = 3 3 horizontal = 0 vertical = 0 determinant = 0 a = 3 3 3 3 3 3 2 2 2 3 3 2 1 0 0 0 0 0 0 0 0 0 0 0 0 indices = 3 4 horizontal = 1 vertical = 0 determinant = 1 a = 3 3 3 3 3 3 2 2 2 3 3 2 1 2 0 0 0 0 0 0 0 0 0 0 0 indices = 3 5 horizontal = 2 vertical = 0 determinant = 2 a = 3 3 3 3 3 3 2 2 2 3 3 2 1 2 3 0 0 0 0 0 0 0 0 0 0 indices = 4 1 horizontal = 2 vertical = 1 determinant = 2 a = 3 3 3 3 3 3 2 2 2 3 3 2 1 2 3 3 0 0 0 0 0 0 0 0 0 indices = 4 2 horizontal = 1 vertical = 1 determinant = 1 a = 3 3 3 3 3 3 2 2 2 3 3 2 1 2 3 3 2 0 0 0 0 0 0 0 0 indices = 4 3 horizontal = 0 vertical = 1 determinant = 1 a = 3 3 3 3 3 3 2 2 2 3 3 2 1 2 3 3 2 2 0 0 0 0 0 0 0 indices = 4 4 horizontal = 1 vertical = 1 determinant = 1 a = 3 3 3 3 3 3 2 2 2 3 3 2 1 2 3 3 2 2 2 0 0 0 0 0 0 indices = 4 5 horizontal = 2 vertical = 1 determinant = 2 a = 3 3 3 3 3 3 2 2 2 3 3 2 1 2 3 3 2 2 2 3 0 0 0 0 0 indices = 5 1 horizontal = 2 vertical = 2 determinant = 2 a = 3 3 3 3 3 3 2 2 2 3 3 2 1 2 3 3 2 2 2 3 3 0 0 0 0 indices = 5 2 horizontal = 1 vertical = 2 determinant = 2 a = 3 3 3 3 3 3 2 2 2 3 3 2 1 2 3 3 2 2 2 3 3 3 0 0 0 indices = 5 3 horizontal = 0 vertical = 2 determinant = 2 a = 3 3 3 3 3 3 2 2 2 3 3 2 1 2 3 3 2 2 2 3 3 3 3 0 0 indices = 5 4 horizontal = 1 vertical = 2 determinant = 2 a = 3 3 3 3 3 3 2 2 2 3 3 2 1 2 3 3 2 2 2 3 3 3 3 3 0 indices = 5 5 horizontal = 2 vertical = 2 determinant = 2 a = 3 3 3 3 3 3 2 2 2 3 3 2 1 2 3 3 2 2 2 3 3 3 3 3 3

2   Pass
n = 7; a = [4 4 4 4 4 4 4; 4 3 3 3 3 3 4; 4 3 2 2 2 3 4; 4 3 2 1 2 3 4; 4 3 2 2 2 3 4; 4 3 3 3 3 3 4; 4 4 4 4 4 4 4]; assert(isequal(bullseye(n),a))

centralindex = 4 a = 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 indices = 1 1 horizontal = 3 vertical = 3 determinant = 3 a = 4 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 indices = 1 2 horizontal = 2 vertical = 3 determinant = 3 a = 4 4 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 indices = 1 3 horizontal = 1 vertical = 3 determinant = 3 a = 4 4 4 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 indices = 1 4 horizontal = 0 vertical = 3 determinant = 3 a = 4 4 4 4 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 indices = 1 5 horizontal = 1 vertical = 3 determinant = 3 a = 4 4 4 4 4 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 indices = 1 6 horizontal = 2 vertical = 3 determinant = 3 a = 4 4 4 4 4 4 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 indices = 1 7 horizontal = 3 vertical = 3 determinant = 3 a = 4 4 4 4 4 4 4 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 indices = 2 1 horizontal = 3 vertical = 2 determinant = 3 a = 4 4 4 4 4 4 4 4 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 indices = 2 2 horizontal = 2 vertical = 2 determinant = 2 a = 4 4 4 4 4 4 4 4 3 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 indices = 2 3 horizontal = 1 vertical = 2 determinant = 2 a = 4 4 4 4 4 4 4 4 3 3 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 indices = 2 4 horizontal = 0 vertical = 2 determinant = 2 a = 4 4 4 4 4 4 4 4 3 3 3 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 indices = 2 5 horizontal = 1 vertical = 2 determinant = 2 a = 4 4 4 4 4 4 4 4 3 3 3 3 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 indices = 2 6 horizontal = 2 vertical = 2 determinant = 2 a = 4 4 4 4 4 4 4 4 3 3 3 3 3 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 indices = 2 7 horizontal = 3 vertical = 2 determinant = 3 a = 4 4 4 4 4 4 4 4 3 3 3 3 3 4 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 indices = 3 1 horizontal = 3 vertical = 1 determinant = 3 a = 4 4 4 4 4 4 4 4 3 3 3 3 3 4 4 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 indices = 3 2 horizontal = 2 vertical = 1 determinant = 2 a = 4 4 4 4 4 4 4 4 3 3 3 3 3 4 4 3 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 indices = 3 3 horizontal = 1 vertical = 1 determinant = 1 a = 4 4 4 4 4 4 4 4 3 3 3 3 3 4 4 3 2 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 indices = 3 4 horizontal = 0 vertical = 1 determinant = 1 a = 4 4 4 4 4 4 4 4 3 3 3 3 3 4 4 3 2 2 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 indices = 3 5 horizontal = 1 vertical = 1 determinant = 1 a = 4 4 4 4 4 4 4 4 3 3 3 3 3 4 4 3 2 2 2 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 indices = 3 6 horizontal = 2 vertical = 1 determinant = 2 a = 4 4 4 4 4 4 4 4 3 3 3 3 3 4 4 3 2 2 2 3 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 indices = 3 7 horizontal = 3 vertical = 1 determinant = 3 a = 4 4 4 4 4 4 4 4 3 3 3 3 3 4 4 3 2 2 2 3 4 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 indices = 4 1 horizontal = 3 vertical = 0 determinant = 3 a = 4 4 4 4 4 4 4 4 3 3 3 3 3 4 4 3 2 2 2 3 4 4 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 indices = 4 2 horizontal = 2 vertical = 0 determinant = 2 a = 4 4 4 4 4 4 4 4 3 3 3 3 3 4 4 3 2 2 2 3 4 4 3 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 indices = 4 3 horizontal = 1 vertical = 0 determinant = 1 a = 4 4 4 4 4 4 4 4 3 3 3 3 3 4 4 3 2 2 2 3 4 4 3 2 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 indices = 4 ...