Cody

# Problem 43801. Union Jack Matrix

Solution 1635023

Submitted on 28 Sep 2018
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   Fail
x = 1; y_correct = 1; assert(isequal(union_jack(x),y_correct))

X = 1 Y = 1 y = 4

Assertion failed.

2   Fail
x = 3; y_correct = ones(3); assert(isequal(union_jack(x),y_correct))

X = 1 2 3 1 2 3 1 2 3 Y = 1 1 1 2 2 2 3 3 3 y = 1 1 1 1 4 1 1 1 1

Assertion failed.

3   Fail
x = 5; y_correct = [1,0,1,0,1; 0,1,1,1,0; 1,1,1,1,1; 0,1,1,1,0; 1,0,1,0,1]; assert(isequal(union_jack(x),y_correct))

X = 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 Y = 1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 4 4 4 4 4 5 5 5 5 5 y = 1 0 1 0 1 0 1 1 1 0 1 1 4 1 1 0 1 1 1 0 1 0 1 0 1

Assertion failed.

4   Fail
x = 7; y_correct = [1,0,0,1,0,0,1; 0,1,0,1,0,1,0; 0,0,1,1,1,0,0; 1,1,1,1,1,1,1; 0,0,1,1,1,0,0; 0,1,0,1,0,1,0; 1,0,0,1,0,0,1]; assert(isequal(union_jack(x),y_correct))

X = 1 2 3 4 5 6 7 1 2 3 4 5 6 7 1 2 3 4 5 6 7 1 2 3 4 5 6 7 1 2 3 4 5 6 7 1 2 3 4 5 6 7 1 2 3 4 5 6 7 Y = 1 1 1 1 1 1 1 2 2 2 2 2 2 2 3 3 3 3 3 3 3 4 4 4 4 4 4 4 5 5 5 5 5 5 5 6 6 6 6 6 6 6 7 7 7 7 7 7 7 y = 1 0 0 1 0 0 1 0 1 0 1 0 1 0 0 0 1 1 1 0 0 1 1 1 4 1 1 1 0 0 1 1 1 0 0 0 1 0 1 0 1 0 1 0 0 1 0 0 1

Assertion failed.

5   Fail
x = 9; y_correct = [1,0,0,0,1,0,0,0,1; 0,1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