Cody

# Problem 780. Give a matrix that matches itself when rotated

Solution 163276

Submitted on 16 Nov 2012 by James
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; s = 1; a = match_rot(n,s); assert(all(ismember(a(:),1:n))) assert(isequal(sum(sum(a == rot90(a))),s))

2   Pass
%% n = 4; s = 16; a = match_rot(n,s); assert(all(ismember(a(:),1:n))) assert(isequal(sum(sum(a == rot90(a))),s))

3   Pass
%% n = 4; s = 7; a = match_rot(n,s); assert(all(ismember(a(:),1:n))) assert(isequal(sum(sum(a == rot90(a))),s))

a = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 a = 1 1 1 1 3 1 1 1 1 1 1 1 1 1 1 1 a = 1 1 2 1 3 1 1 1 1 1 1 1 1 1 1 1 a = 1 1 2 1 3 1 1 1 1 1 1 1 1 1 1 4 a = 1 1 2 1 3 1 1 1 1 1 1 1 1 1 1 1 a = 1 1 2 1 3 1 1 1 1 1 1 1 1 4 1 1 a = 1 1 2 1 3 1 1 1 4 1 1 1 1 4 1 1 a = 1 1 2 1 3 1 1 1 4 1 1 2 1 4 1 1 a = 1 1 2 1 3 1 1 1 4 1 1 2 1 4 1 4 a = 3 1 2 1 3 1 1 1 4 1 1 2 1 4 1 4

4   Pass
%% n = 5; s = 8; a = match_rot(n,s); assert(all(ismember(a(:),1:n))) assert(isequal(sum(sum(a == rot90(a))),s))

a = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 5 1 1 1 1 1 a = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 4 5 1 1 1 1 1 a = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 4 5 1 4 1 1 1 a = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 4 5 4 4 1 1 1 a = 4 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 4 5 4 4 1 1 1 a = 4 1 1 1 1 2 1 1 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