Cody

# Problem 4. Make a checkerboard matrix

Solution 2182568

Submitted on 30 Mar 2020 by Jeff Connors
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)))

b = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = 2 3 4 5 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = 2 3 4 5 6 3 4 5 6 7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = 2 3 4 5 6 3 4 5 6 7 4 5 6 7 8 0 0 0 0 0 0 0 0 0 0 b = 2 3 4 5 6 3 4 5 6 7 4 5 6 7 8 5 6 7 8 9 0 0 0 0 0 b = 2 3 4 5 6 3 4 5 6 7 4 5 6 7 8 5 6 7 8 9 6 7 8 9 10 a = 5×5 logical array 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)))

b = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = 2 3 4 5 0 0 0 0 0 0 0 0 0 0 0 0 b = 2 3 4 5 3 4 5 6 0 0 0 0 0 0 0 0 b = 2 3 4 5 3 4 5 6 4 5 6 7 0 0 0 0 b = 2 3 4 5 3 4 5 6 4 5 6 7 5 6 7 8 a = 4×4 logical array 1 0 1 0 0 1 0 1 1 0 1 0 0 1 0 1

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)))

b = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = 2 3 4 5 6 7 8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = 2 3 4 5 6 7 8 3 4 5 6 7 8 9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = 2 3 4 5 6 7 8 3 4 5 6 7 8 9 4 5 6 7 8 9 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = 2 3 4 5 6 7 8 3 4 5 6 7 8 9 4 5 6 7 8 9 10 5 6 7 8 9 10 11 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = 2 3 4 5 6 7 8 3 4 5 6 7 8 9 4 5 6 7 8 9 10 5 6 7 8 9 10 11 6 7 8 9 10 11 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = 2 3 4 5 6 7 8 3 4 5 6 7 8 9 4 5 6 7 8 9 10 5 6 7 8 9 10 11 6 7 8 9 10 11 12 7 8 9 10 11 12 13 0 0 0 0 0 0 0 b = 2 3 4 5 6 7 8 3 4 5 6 7 8 9 4 5 6 7 8 9 10 5 6 7 8 9 10 11 6 7 8 9 10 11 12 7 8 9 10 11 12 13 8 9 10 11 12 13 14 a = 7×7 logical array 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!