Cody

# Problem 42319. How close to a hole

Solution 2951002

Submitted on 15 Sep 2020 by Catherine Jones
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
x = [0 0 1 1 1 0]; y_correct = [0 0 1 2 1 0]; assert(isequal(distancesFromHoles(x),y_correct))

idx_zero = 1 2 3 7 8

2   Pass
x = [1 1 1 0 0 1 1 0 1 1 1 1 1 1 1]; y_correct = [1 2 1 0 0 1 1 0 1 2 3 4 3 2 1]; assert(isequal(distancesFromHoles(x),y_correct))

idx_zero = 1 5 6 9 17

3   Pass
x = [ones(1,10),0,ones(1,10)]; y_correct = [1:5,5:-1:0,1:5,5:-1:1]; assert(isequal(distancesFromHoles(x),y_correct))

idx_zero = 1 12 23

4   Pass
x = [1 1 1 0 0 0 0 0 0 0 0 0 1 1 1]; y_correct = [1 2 1 0 0 0 0 0 0 0 0 0 1 2 1]; assert(isequal(distancesFromHoles(x),y_correct))

idx_zero = 1 5 6 7 8 9 10 11 12 13 17

5   Pass
x = ones(1,101); y_correct = [1:51,50:-1:1]; assert(isequal(distancesFromHoles(x),y_correct))

idx_zero = 1 103

6   Pass
x = [repmat([1,0],[1,50]),1]; y_correct = x; assert(isequal(distancesFromHoles(x),y_correct))

idx_zero = Columns 1 through 30 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 Columns 31 through 52 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 101 103

### Community Treasure Hunt

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

Start Hunting!