Cody

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

Solution 2530824

Submitted on 12 Jun 2020 by Antoni Prus
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))

y = 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

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

y = 2 2 2 1

3   Pass
y_correct = [9 8 7 6 5 4 3 2 1 2; ... 9 8 7 6 5 4 3 2 2 2; 9 8 7 6 5 4 3 3 3 3; ... 9 8 7 6 5 4 4 4 4 4; 9 8 7 6 5 5 5 5 5 5; ... 9 8 7 6 6 6 6 6 6 6; 9 8 7 7 7 7 7 7 7 7; ... 9 8 8 8 8 8 8 8 8 8; 9 9 9 9 9 9 9 9 9 9; ... 10 10 10 10 10 10 10 10 10 10]; assert(isequal(safety_map(10,1,9),y_correct))

y = 9 8 7 6 5 4 3 2 1 2 9 8 7 6 5 4 3 2 2 2 9 8 7 6 5 4 3 3 3 3 9 8 7 6 5 4 4 4 4 4 9 8 7 6 5 5 5 5 5 5 9 8 7 6 6 6 6 6 6 6 9 8 7 7 7 7 7 7 7 7 9 8 8 8 8 8 8 8 8 8 9 9 9 9 9 9 9 9 9 9 10 10 10 10 10 10 10 10 10 10

4   Pass
y_correct = 1; assert(isequal(safety_map(1,1,1),y_correct))

y = 1

5   Pass
y_correct = [4 3 2 2; ... 4 3 2 1; 4 3 2 2; 4 3 3 3]; assert(isequal(safety_map(4,2,4),y_correct))

y = 4 3 2 2 4 3 2 1 4 3 2 2 4 3 3 3

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

y = 2 1 2 2

7   Pass
y_correct = [4 4 4 4 4 4 4; 4 3 3 3 3 3 4; ... 4 3 2 2 2 3 4; 4 3 2 1 2 3 4; 4 3 2 2 2 3 4; ... 4 3 3 3 3 3 4; 4 4 4 4 4 4 4]; assert(isequal(safety_map(7,4,4),y_correct))

y = 4 4 4 4 4 4 4 4 3 3 3 3 3 4 4 3 2 2 2 3 4 4 3 2 1 2 3 4 4 3 2 2 2 3 4 4 3 3 3 3 3 4 4 4 4 4 4 4 4

8   Pass
y_correct = [10 10 10 10 10 10 10 10 10 10; ... 10 9 9 9 9 9 9 9 9 9; 10 9 8 8 8 8 8 8 8 8; ... 10 9 8 7 7 7 7 7 7 7; 10 9 8 7 6 6 6 6 6 6; ... 10 9 8 7 6 5 5 5 5 5; 10 9 8 7 6 5 4 4 4 4; ... 10 9 8 7 6 5 4 3 3 3; 10 9 8 7 6 5 4 3 2 2; ... 10 9 8 7 6 5 4 3 2 1]; assert(isequal(safety_map(10,10,10),y_correct))

y = 10 10 10 10 10 10 10 10 10 10 10 9 9 9 9 9 9 9 9 9 10 9 8 8 8 8 8 8 8 8 10 9 8 7 7 7 7 7 7 7 10 9 8 7 6 6 6 6 6 6 10 9 8 7 6 5 5 5 5 5 10 9 8 7 6 5 4 4 4 4 10 9 8 7 6 5 4 3 3 3 10 9 8 7 6 5 4 3 2 2 10 9 8 7 6 5 4 3 2 1

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

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

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!