Cody

# Problem 4. Make a checkerboard matrix

Solution 433393

Submitted on 17 Apr 2014 by Joel
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 = [1 0 1 0 1; 0 1 0 1 0; 1 0 1 0 1; 0 1 0 1 0; 1 0 1 0 1]; assert(isequal(a,checkerboard(n)))

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 ii = 1 k = 1 t = 1 a = 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 k = 2 a = 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 k = 3 a = 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 k = 4 a = 1 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 k = 5 a = 1 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 1 0 0 0 1 0 0 0 0 k = 6 a = 1 0 1 0 0 0 1 0 0 0 1 0 0 0 0 0 1 0 0 0 1 0 0 0 0 k = 7 a = 1 0 1 0 0 0 1 0 0 0 1 0 1 0 0 0 1 0 0 0 1 0 0 0 0 k = 8 a = 1 0 1 0 0 0 1 0 0 0 1 0 1 0 0 0 1 0 0 0 1 0 1 0 0 k = 9 a = 1 0 1 0 0 0 1 0 1 0 1 0 1 0 0 0 1 0 0 0 1 0 1 0 0 k = 10 a = 1 0 1 0 0 0 1 0 1 0 1 0 1 0 0 0 1 0 1 0 1 0 1 0 0 k = 11 a = 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 0 1 0 1 0 1 0 1 0 0 k = 12 a = 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 k = 13 columns = 1 t = 2 columns = 1 2 t = 3 columns = 1 2 3 t = 4 columns = 1 2 3 4 t = 5 columns = 1 2 3 4 5 t = 6 a = 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1

2   Pass
n = 4; a = [1 0 1 0; 0 1 0 1; 1 0 1 0; 0 1 0 1]; assert(isequal(a,checkerboard(n)))

a = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ii = 1 k = 1 t = 1 a = 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 k = 2 a = 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 k = 3 a = 1 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 k = 4 a = 1 1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 k = 5 a = 1 1 1 0 0 0 0 0 1 1 0 0 0 0 0 0 k = 6 a = 1 1 1 0 0 0 0 0 1 1 1 0 0 0 0 0 k = 7 a = 1 1 1 1 0 0 0 0 1 1 1 0 0 0 0 0 k = 8 a = 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 k = 9 columns = 1 t = 2 columns = 1 2 t = 3 columns = 1 2 3 t = 4 columns = 1 2 3 4 t = 5 ii = 2 c = 2 4 d = 1 3 a = 1 1 1 1 0 1 0 0 1 1 1 1 0 1 0 0 a = 1 0 1 1 0 1 0 0 1 0 1 1 0 1 0 0 ii = 3 ii = 4 c = 2 4 d = 1 3 a = 1 0 1 1 0 1 0 1 1 0 1 1 0 1 0 1 a = 1 0 1 0 0 1 0 1 1 0 1 0 0 1 0 1 ii = 5

3   Pass
n = 7; a = [1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1]; assert(isequal(a,checkerboard(n)))

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 ii = 1 k = 1 t = 1 a = 1 0 0 0 0 0 0 0 0 0 0 0 0 0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 0 1 0 0 0 1 0 1 0 0 0 1 0 1 0 1 0 0 k = 21 a = 1 0 1 0 1 0 0 0 1 0 1 0 1 0 1 0 1 0 1 0 0 0 1 0 1 0 1 0 1 0 1 0 1 0 0 0 1 0 1 0 1 0 1 0 1 0 1 0 0 k = 22 a = 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 0 1 0 1 0 1 0 1 0 1 0 1 0 0 0 1 0 1 0 1 0 1 0 1 0 1 0 0 k = 23 a = 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 0 1 0 1 0 1 0 1 0 1 0 1 0 0 k = 24 a = 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 k = 25 columns = 1 t = 2 columns = 1 2 t = 3 columns = 1 2 3 t = 4 columns = 1 2 3 4 t = 5 columns = 1 2 3 4 5 t = 6 columns = 1 2 3 4 5 6 t = 7 columns = 1 2 3 4 5 6 7 t = 8 a = 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!