Cody

# Problem 44063. Make a rainbow matrix (follow-up to checkerboard matrix)

Solution 1119624

Submitted on 10 Feb 2017 by James
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

This solution is outdated. To rescore this solution, sign in.

### Test Suite

Test Status Code Input and Output
1   Pass
n = 3; a_correct = [0 1 2; 1 2 1; 2 1 0]; assert(isequal(rainBowMatrix(n),a_correct))

h = 0 1 2 1 2 -1 2 -1 -1 t = 0 1 2 1 2 1 2 1 0

2   Pass
n = 8; a_correct = [0 1 2 3 4 5 6 7; 1 2 3 4 5 6 7 6; 2 3 4 5 6 7 6 5; 3 4 5 6 7 6 5 4; 4 5 6 7 6 5 4 3; 5 6 7 6 5 4 3 2; 6 7 6 5 4 3 2 1; 7 6 5 4 3 2 1 0]; assert(isequal(rainBowMatrix(n),a_correct))

h = 0 1 2 3 4 5 6 7 1 2 3 4 5 6 7 -1 2 3 4 5 6 7 -1 -1 3 4 5 6 7 -1 -1 -1 4 5 6 7 -1 -1 -1 -1 5 6 7 -1 -1 -1 -1 -1 6 7 -1 -1 -1 -1 -1 -1 7 -1 -1 -1 -1 -1 -1 -1 t = 0 1 2 3 4 5 6 7 1 2 3 4 5 6 7 6 2 3 4 5 6 7 6 5 3 4 5 6 7 6 5 4 4 5 6 7 6 5 4 3 5 6 7 6 5 4 3 2 6 7 6 5 4 3 2 1 7 6 5 4 3 2 1 0

### Community Treasure Hunt

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

Start Hunting!