Cody

# Problem 45395. Create a matrix map of increasing safety levels

Solution 3616100

Submitted on 11 Nov 2020 by Christopher DeRocher
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
y_correct = [3 2 2 2 3 4; 3 2 1 2 3 4; ... 3 2 2 2 3 4; 3 3 3 3 3 4; 4 4 4 4 4 4; ... 5 5 5 5 5 5]; assert(isequal(safety_map(6,2,3),y_correct))

f = 0 2 0 0 0 0 0 0 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 0 0 0 f = 0 2 2 0 0 0 0 0 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 0 0 0 f = 0 2 2 2 0 0 0 0 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 0 0 0 f = 0 2 2 2 0 0 0 2 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 0 0 0 f = 0 2 2 2 0 0 0 2 1 2 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 f = 0 2 2 2 0 0 0 2 1 2 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 f = 0 2 2 2 0 0 0 2 1 2 0 0 0 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 f = 0 2 2 2 0 0 0 2 1 2 0 0 0 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 f = 3 2 2 2 0 0 0 2 1 2 0 0 0 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 f = 3 2 2 2 3 0 0 2 1 2 0 0 0 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 f = 3 2 2 2 3 0 3 2 1 2 0 0 0 2 2 2 0 0 0 0 0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; 1 2 3]; assert(isequal(safety_map(3,3,1),y_correct))

f = 0 0 0 2 0 0 1 0 0 f = 0 0 0 2 2 0 1 0 0 f = 0 0 0 2 2 0 1 2 0 f = 3 0 0 2 2 0 1 2 0 f = 3 3 0 2 2 0 1 2 0 f = 3 3 3 2 2 0 1 2 0 f = 3 3 3 2 2 3 1 2 0 f = 3 3 3 2 2 3 1 2 3 y = 3 3 3 2 2 3 1 2 3

10   Pass
y_correct = [2 1 2; 2 2 2; 3 3 3]; assert(isequal(safety_map(3,1,2),y_correct))

f = 2 1 0 0 0 0 0 0 0 f = 2 1 2 0 0 0 0 0 0 f = 2 1 2 2 0 0 0 0 0 f = 2 1 2 2 2 0 0 0 0 f = 2 1 2 2 2 2 0 0 0 f = 2 1 2 2 2 2 3 0 0 f = 2 1 2 2 2 2 3 3 0 f = 2 1 2 2 2 2 3 3 3 y = 2 1 2 2 2 2 3 3 3

### Community Treasure Hunt

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

Start Hunting!