Cody

Problem 18. Bullseye Matrix

Solution 717154

Submitted on 19 Aug 2015 by Nicholas Hortance
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));

a = 3 3 3 3 3 3 0 0 0 3 3 0 0 0 3 3 0 0 0 3 3 0 0 0 3 a = 3 3 3 3 3 3 2 2 2 3 3 0 0 0 3 3 0 0 0 3 3 0 0 0 3 a = 3 3 3 3 3 3 2 2 2 3 3 0 1 0 3 3 0 0 0 3 3 0 0 0 3 a = 3 3 3 3 3 3 2 2 2 3 3 0 1 0 3 3 0 0 0 3 3 0 0 0 3 a = 3 3 3 3 3 3 2 2 2 3 3 0 1 0 3 3 0 0 0 3 3 0 0 0 3 a = 3 3 3 3 3 3 2 2 2 3 3 0 1 0 3 3 0 0 0 3 3 3 3 3 3 a = 3 3 3 3 3 3 2 2 2 3 3 0 1 0 3 3 2 2 2 3 3 3 3 3 3 a = 3 3 3 3 3 3 2 2 2 3 3 0 1 0 3 3 2 2 2 3 3 3 3 3 3 a = 3 3 3 3 3 3 2 2 2 3 3 0 1 0 3 3 2 2 2 3 3 3 3 3 3 a = 3 3 3 3 3 3 2 2 2 3 3 0 1 0 3 3 2 2 2 3 3 3 3 3 3 a = 3 3 3 3 3 3 2 2 2 3 3 2 1 0 3 3 2 2 2 3 3 3 3 3 3 a = 3 3 3 3 3 3 2 2 2 3 3 2 1 0 3 3 2 2 2 3 3 3 3 3 3 a = 3 3 3 3 3 3 2 2 2 3 3 2 1 0 3 3 2 2 2 3 3 3 3 3 3 a = 3 3 3 3 3 3 2 2 2 3 3 2 1 0 3 3 2 2 2 3 3 3 3 3 3 a = 3 3 3 3 3 3 2 2 2 3 3 2 1 0 3 3 2 2 2 3 3 3 3 3 3 a = 3 3 3 3 3 3 2 2 2 3 3 2 1 2 3 3 2 2 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