Cody

# Problem 45432. Pitting corrosion on a metal plate: Find the largest pit

Solution 2541399

Submitted on 13 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

filetext = 'function y = largest_pit(X) if ~any(X==1) y = 0 else n=size(X,1); m=size(X,2); cord = []; for a=1:n for b=1:m if X(a,b) == 1 cord = [cord; [a b]]; end end end con = []; for c=1:size(cord,1) same = max(abs(cord(c, 1)-cord(:,1)),abs(cord(c,2)-cord(:,2))) <= 1; con = [con same]; end cord = [cord zeros(size(cord,1),1)]; conLog = con == 1; n = 1; for d = 1:size(con,2) if max(cord(conLog(:,d),3)) == 0 cord(conLog(:,d),3) = n; n = n+1; elseif nnz(unique(cord(conLog(:,d),3))) <= 1 un1 = unique(cord(conLog(:,d),3)) cord(d,3) = max(cord(conLog(:,d),3)); else un = unique(cord(conLog(:,d),3)) un = un(un~=0) for f = 1:length(un) cord((cord(:,3) == un(f)),3) =n; end cord(d, 3) = n; n= n+1; end end g = unique(cord(:,3)) h = zeros(1, size(g,1)) for e=1:size(g,1) h(1,e) = nnz(cord(:,3)==g(e)) end y=max(h) end end %This code written by profile_id 15735109 '

2   Pass
x = 1; y_correct = 1; assert(isequal(largest_pit(x),y_correct))

g = 1 h = 0 h = 1 y = 1

3   Pass
x = 0; y_correct = 0; assert(isequal(largest_pit(x),y_correct))

y = 0

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

g = 1 2 3 h = 0 0 0 h = 1 0 0 h = 1 1 0 h = 1 1 1 y = 1

5   Pass
x = [ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 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 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 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 2 1 3 1 1 1 1 1 7 1 2 0 0 h = 1 1 1 2 1 1 1 1 4 1 1 1 2 1 3 1 1 1 1 1 7 1 2 1 0 h = 1 1 1 2 1 1 1 1 4 1 1 1 2 1 3 1 1 1 1 1 7 1 2 1 2 y = 7

6   Pass
x = [ 0 1 1 1 0 1 1 1 0 0 0 0 0 0 1 0 1 1 1 0 0 1 1 0 0 0 0 0 0 0 1 1 0 1 1 1 1 0 1 0 1 1 0 0 0 1 0 0 1 1 1 0 0 0 0 1 0 0 0 0 1 1 0 1 1 1 0 1 0 1 0 0 0 1 1 1 1 1 0 0 0 0 1 1 0 1 0 1 1 1 0 1 0 1 0 1 0 1 0 0]; assert(isequal(largest_pit(x),34))

un1 = 0 1 un1 = 0 1 un1 = 0 2 un1 = 0 2 un = 1 2 un = 1 2 un1 = 0 3 un1 = 0 3 un1 = 0 3 un1 = 0 4 un1 = 0 4 un1 = 0 4 un1 = 0 4 un1 = 0 4 un1 = 0 4 un1 = 0 4 un1 = 0 4 un1 = 0 4 un1 = 0 4 un1 = 5 un1 = 5 un1 = 0 4 un1 = 0 4 un1 = 0 4 un1 = 0 4 un = 0 4 6 un = 4 6 un1 = 0 7 un1 = 0 7 un1 = 0 7 un = 0 7 8 un = 7 8 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 10 g = 3 5 9 10 h = 0 0 0 0 h = 10 0 0 0 h = 10 3 0 0 h = 10 3 1 0 h = 10 3 1 34 y = 34

7   Pass
x = [ 0 0 0 1 0 1 1 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 1 1 0 1 1 0 1 0 0 0 0 0 0 0 0 0 0 1 1 0 1 1 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 1 0 0 0 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0 1 1 0 0 0 1 1 0 0 0 0 0 0 0 1 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 0 1 1 0 1 0 0 0 0 0 0 1 0 1 1 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 1 1 0 1 0 0 0 0 0 1 0 0 0 0 1 0 1 0 1 1 0 0 0 0 0 0 1 1 0 1 1 1 0 0 0 0 0 0 1 0 1 1 0 0 1 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 1 1 1 0 1 0 0 0 0 0 0 0 0 0 1 0 1 1 1 0 0 1 1 0 0 0 0 1 0 0 0]; assert(isequal(largest_pit(x),15))

un1 = 0 1 un1 = 3 un1 = 5 un1 = 0 1 un1 = 0 1 un1 = 6 un1 = 0 3 un1 = 4 un1 = 0 5 un1 = 0 6 un1 = 0 6 un1 = 0 3 un1 = 0 3 un1 = 0 5 un1 = 0 6 un1 = 0 6 un1 = 0 3 un1 = 0 7 un1 = 0 5 un1 = 0 6 un1 = 8 un = 0 5 7 un = 5 7 un = 0 6 10 un = 6 10 un1 = 0 11 un1 = 8 un1 = 0 9 un1 = 0 11 un1 = 0 11 un1 = 14 un1 = 0 12 un1 = 0 12 un1 = 0 12 un1 = 0 11 un1 = 0 11 un1 = 0 11 un1 = 0 12 un1 = 0 15 un1 = 0 15 un1 = 0 15 un1 = 0 15 un1 = 0 12 un = 0 15 18 un = 15 18 un1 = 0 19 un1 = 0 19 un1 = 0 19 g = 1 2 3 4 8 9 11 12 13 14 16 17 19 20 h = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 h = 4 0 0 0 0 0 0 0 0 0 0 0 0 0 h = 4 1 0 0 0 0 0 0 0 0 0 0 0 0 h = 4 1 6 0 0 0 0 0 0 0 0 0 0 0 h = 4 1 6 2 0 0 0 0 0 0 0 0 0 0 h = 4 1 6 2 3 0 0 0 0 0 0 0 0 0 h = 4 1 6 2 3 9 0 0 0 0 0 0 0 0 h = 4 1 6 2 3 9 15 0 0 0 0 0 0 0 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 0 0 0 0]; assert(isequal(largest_pit(x),27))

un1 = 0 3 un1 = 0 4 un1 = 0 4 un1 = 0 4 un1 = 0 5 un1 = 0 6 un1 = 0 3 un1 = 0 3 un1 = 0 4 un1 = 0 5 un1 = 0 6 un1 = 0 7 un1 = 0 3 un1 = 0 3 un1 = 0 5 un1 = 0 5 un1 = 0 6 un1 = 0 7 un1 = 0 7 un1 = 0 3 un1 = 0 3 un1 = 0 3 un1 = 0 5 un = 0 6 8 un = 6 8 un1 = 0 10 un1 = 0 3 un1 = 0 9 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 3 un1 = 0 9 un1 = 0 9 un1 = 12 un1 = 0 10 un1 = 0 10 un1 = 13 un1 = 0 11 un1 = 0 11 un = 3 14 un = 3 14 un1 = 0 9 un1 = 0 10 un = 0 10 13 un = 10 13 un1 = 0 11 un1 = 0 15 un1 = 0 9 un1 = 0 17 un1 = 0 15 un1 = 0 9 un1 = 0 9 un1 = 0 17 un1 = 0 19 un1 = 0 15 un = 0 9 15 un = 9 15 un1 = 0 21 un1 = 0 17 un1 = 0 19 un1 = 0 19 un1 = 0 19 un1 = 0 21 un1 = 0 22 un1 = 0 22 un1 = 0 17 un1 = 0 19 un1 = 0 22 un1 = 0 17 un1 = 0 19 un1 = 0 19 un1 = 0 17 un1 = 27 un = 19 24 un = 19 24 un1 = 0 25 un1 = 26 un1 = 0 17 un1 = 0 27 un1 = 0 27 un1 = 30 un1 = 0 25 un1 = 29 un1 = 0 27 un1 = 0 27 un1 = 0 27 un1 = 0 27 un1 = 0 25 un1 = 0 25 un1 = 0 27 un1 = 0 27 un = 0 25 33 un = 25 33 un1 = 0 34 un1 = 0 32 un1 = 0 27 un = 0 27 32 un = 27 32 un = 0 35 38 un = 35 38 un1 = 39 un1 = 39 g = 1 2 4 5 7 11 12 16 17 18 20 21 22 23 26 28 29 30 31 34 36 37 39 40 h = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 h = 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 un1 = 0 7 un1 = 0 6 un1 = 0 5 un1 = 0 5 un1 = 0 5 un1 = 0 5 un = 0 5 7 un = 5 7 un1 = 0 8 un1 = 0 8 un1 = 0 8 un1 = 0 8 un1 = 0 8 un1 = 0 6 un1 = 0 6 un1 = 0 8 un1 = 0 8 un1 = 0 8 un1 = 0 8 un1 = 0 8 un1 = 0 8 un1 = 0 8 un1 = 0 8 un1 = 0 8 un1 = 0 8 un1 = 0 6 un1 = 0 8 un1 = 0 8 un1 = 0 8 un1 = 0 8 un1 = 0 8 un1 = 0 8 un1 = 0 8 un1 = 0 8 un1 = 0 6 un1 = 0 6 un1 = 0 8 un1 = 0 8 un1 = 0 8 un = 8 9 un = 8 9 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 6 un1 = 0 6 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 6 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 11 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 10 un = 0 11 12 un = 11 12 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 13 un = 0 10 13 un = 10 13 un1 = 0 14 un1 = 0 14 un1 = 0 14 un1 = 0 14 un1 = 0 14 un1 = 0 14 un1 = 0 14 un1 = 0 14 un1 = 0 14 un1 = 0 14 un1 = 0 14 un1 = 0 15 un1 = 0 14 un1 = 0 14 un1 = 0 14 un1 = 0 14 un1 = 0 14 un1 = 0 14 un = 0 15 16 un = 15 16 un1 = 0 18 un1 = 0 18 un1 = 0 17 un1 = 0 14 un1 = 0 14 un1 = 0 14 un1 = 0 14 un1 = 0 14 un1 = 0 14 un1 = 0 18 un1 = 0 18 un1 = 0 18 un1 = 0 17 un1 = 0 14 un1 = 0 14 un1 = 0 14 un1 = 0 14 un1 = 0 14 un1 = 0 14 un1 = 0 14 un = 0 14 18 un = 14 18 un1 = 0 19 un1 = 0 19 un1 = 0 17 un1 = 0 19 un1 = 0 19 un1 = 0 19 un1 = 0 19 un1 = 0 19 un1 = 0 19 un1 = 0 19 un1 = 0 19 un1 = 0 19 un1 = 0 19 un = 0 17 19 un = 17 19 g = 1 2 6 20 h = 0 0 0 0 h = 1 0 0 0 h = 1 1 0 0 h = 1 1 10 0 h = 1 1 10 150 y = 150

12   Pass
x = repmat([1 1 1 0;1 0 1 0;1 1 1 0; 0 0 0 0],4,5); assert(isequal(largest_pit(x),8))

un1 = 0 1 un1 = 0 1 un1 = 0 2 un1 = 0 2 un1 = 0 3 un1 = 0 3 un1 = 0 4 un1 = 0 4 un1 = 0 5 un1 = 0 5 un1 = 0 1 un1 = 0 1 un1 = 0 2 un1 = 0 2 un1 = 0 3 un1 = 0 3 un1 = 0 4 un1 = 0 4 un1 = 0 5 un1 = 0 5 un1 = 0 1 un1 = 0 1 un1 = 0 1 un1 = 0 2 un1 = 0 2 un1 = 0 2 un1 = 0 3 un1 = 0 3 un1 = 0 3 un1 = 0 4 un1 = 0 4 un1 = 0 4 un1 = 0 5 un1 = 0 5 un1 = 0 5 un1 = 0 6 un1 = 0 6 un1 = 0 7 un1 = 0 7 un1 = 0 8 un1 = 0 8 un1 = 0 9 un1 = 0 9 un1 = 0 10 un1 = 0 10 un1 = 0 6 un1 = 0 6 un1 = 0 7 un1 = 0 7 un1 = 0 8 un1 = 0 8 un1 = 0 9 un1 = 0 9 un1 = 0 10 un1 = 0 10 un1 = 0 6 un1 = 0 6 un1 = 0 6 un1 = 0 7 un1 = 0 7 un1 = 0 7 un1 = 0 8 un1 = 0 8 un1 = 0 8 un1 = 0 9 un1 = 0 9 un1 = 0 9 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 11 un1 = 0 11 un1 = 0 12 un1 = 0 12 un1 = 0 13 un1 = 0 13 un1 = 0 14 un1 = 0 14 un1 = 0 15 un1 = 0 15 un1 = 0 11 un1 = 0 11 un1 = 0 12 un1 = 0 12 un1 = 0 13 un1 = 0 13 un1 = 0 14 un1 = 0 14 un1 = 0 15 un1 = 0 15 un1 = 0 11 un1 = 0 11 un1 = 0 11 un1 = 0 12 un1 = 0 12 un1 = 0 12 un1 = 0 13 un1 = 0 13 un1 = 0 13 un1 = 0 14 un1 = 0 14 un1 = 0 14 un1 = 0 15 un1 = 0 15 un1 = 0 15 un1 = 0 16 un1 = 0 16 un1 = 0 17 un1 = 0 17 un1 = 0 18 un1 = 0 18 un1 = 0 19 un1 = 0 19 un1 = 0 20 un1 = 0 20 un1 = 0 16 un1 = 0 16 un1 = 0 17 un1 = 0 17 un1 = 0 18 un1 = 0 18 un1 = 0 19 un1 = 0 19 un1 = 0 20 un1 = 0 20 un1 = 0 16 un1 = 0 16 un1 = 0 16 un1 = 0 17 un1 = 0 17 un1 = 0 17 un1 = 0 18 un1 = 0 18 un1 = 0 18 un1 = 0 19 un1 = 0 19 un1 = 0 19 un1 = 0 20 un1 = 0 20 un1 = 0 20 g = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 h = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 h = 8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 h = 8 8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 h = 8 8 8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 h = 8 8 8 8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 h = 8 8 8 8 8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 h = 8 8 8 8 8 8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 h = 8 8 8 8 8 8 8 0 0 0 0 0 0 0 0 0 0 0 0 0 h = 8 8 8 8 8 8 8 8 0 0 0 0 0 0 0 0 0 0 0 0 h = 8 8 8 8 8 8 8 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0 0 1 0 1 0 1 0 0 0 1 1 0 0 1 1 0 1 0 1 0 1 1 0 1 0 1 0 0 1 0 1 0 1 0 1 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 1 1 0 0 0 0 0 1 0 0 0 1 0 1 1 0 1 1 0 0 1 1 0 0 0 1 0 0 0 0 1 1 0 0 1 0 1 1 1 0 0 0 0 0 0 1 0 0 1 0 0 1 0 1 1 0 1 0 0 1 0 1 0 0 0 1 1 1 1 1 1 1 1 0 0 1 0 1 1 1 0 1 1 0 0 0 0 1 0 0 0 1 1 0 0 0 0 0 0 1 1 0 0 1 0 0 1 0 1 1 1 1 0 1 1 0 0 0 1 0 0 0 1 0 0 1 0 0 1 1 1 0 0 1 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 1 0]; assert(isequal(largest_pit(x),91))

un1 = 0 3 un1 = 0 3 un1 = 0 3 un1 = 0 4 un1 = 0 4 un1 = 0 4 un1 = 0 1 un1 = 0 2 un1 = 0 4 un1 = 0 4 un1 = 0 1 un1 = 0 2 un1 = 0 6 un1 = 0 6 un1 = 0 6 un1 = 0 4 un1 = 0 4 un1 = 0 4 un = 0 6 8 un = 6 8 un1 = 0 4 un1 = 0 4 un1 = 0 7 un = 9 10 un = 9 10 un1 = 11 un1 = 11 un1 = 0 11 un1 = 0 11 un1 = 0 11 un1 = 0 4 un1 = 0 7 un1 = 0 11 un1 = 0 11 un1 = 12 un = 0 7 13 un = 7 13 un1 = 0 11 un1 = 0 15 un1 = 0 11 un1 = 0 14 un1 = 0 14 un1 = 0 14 un = 0 11 15 un = 11 15 un1 = 0 17 un1 = 0 17 un1 = 0 17 un1 = 0 17 un1 = 0 16 un1 = 0 16 un1 = 0 16 un1 = 0 14 un1 = 0 14 un1 = 0 17 un1 = 0 17 un1 = 0 17 un = 0 16 17 un = 16 17 un1 = 0 18 un1 = 0 18 un1 = 0 18 un1 = 0 14 un1 = 0 18 un1 = 0 18 un1 = 0 18 un1 = 0 18 un1 = 0 14 un1 = 19 un1 = 0 18 un1 = 0 18 un1 = 0 18 un1 = 0 18 un1 = 0 18 un1 = 0 14 un1 = 0 19 un1 = 19 un1 = 0 18 un1 = 0 18 un = 0 14 19 un = 14 19 un1 = 0 22 un1 = 0 18 un1 = 0 18 un1 = 0 18 un1 = 0 24 un1 = 0 22 un1 = 0 22 un1 = 0 18 un1 = 0 18 un1 = 0 18 un1 = 0 24 un1 = 0 24 un1 = 0 24 un1 = 0 25 un1 = 0 18 un1 = 0 18 un1 = 0 18 un1 = 0 24 un1 = 0 25 un = 0 25 26 un = 25 26 un1 = 0 29 un1 = 0 29 un1 = 0 29 un = 0 18 29 un = 18 29 un1 = 0 30 un1 = 0 30 un = 0 24 30 un = 24 30 un1 = 0 31 un1 = 0 31 un1 = 0 27 un1 = 0 28 un1 = 0 28 un1 = 0 31 un1 = 0 31 un1 = 0 31 un1 = 0 27 un = 0 27 28 un = 27 28 un1 = 0 32 un1 = 0 31 un1 = 0 31 un1 = 0 31 un1 = 0 31 un1 = 0 31 un1 = 0 31 un1 = 0 31 un1 = 0 32 un1 = 0 31 un1 = 0 31 un1 = 0 31 un1 = 0 31 un1 = 0 31 un1 = 0 33 un1 = 0 32 un1 = 0 31 un1 = 0 33 g = 1 2 3 4 5 12 20 21 22 23 31 32 33 34 h = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 h = 3 0 0 0 0 0 0 0 0 0 0 0 0 0 h = 3 3 0 0 0 0 0 0 0 0 0 0 0 0 h = 3 3 4 0 0 0 0 0 0 0 0 0 0 0 h = 3 3 4 12 0 0 0 0 0 0 0 0 0 0 h = 3 3 4 12 1 0 0 0 0 0 0 0 0 0 h = 3 3 4 12 1 2 0 0 0 0 0 0 0 0 h = 3 3 4 12 1 2 1 0 0 0 0 0 0 0 h = 3 3 4 12 1 2 1 1 0 0 0 0 0 0 h = 3 3 4 12 1 2 1 1 21 0 0 0 0 0 h = 3 3 4 12 1 2 1 1 21 1 0 0 0 0 h = 3 3 4 12 1 2 1 1 21 1 91 0 0 0 h = 3 3 4 12 1 2 1 1 21 1 91 10 0 0 h = 3 3 4 12 1 2 1 1 21 1 91 10 3 0 h = 3 3 4 12 1 2 1 1 21 1 91 10 3 1 y = 91

15   Pass
x = [ 0 1 0 0 1 1 0 1 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 0 0 1 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 1 1 0 0 0 0 1 0 0 0 1 1 1 0 1 1 1 0 1 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 1 0 0 0 1 0 0 0 1 0 0 1 1 0 1 0 0 0 0 0 1 0 0 1 1 0 0 0 0 0 0 0 0 1 0 1 1 0 1 1 0 0 1 0 1 1 0 0 0 0 1 1 0 1 0 0 1 0 0 1 1 0 1 0 0 0 0 0 1 0 1 1 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0]; assert(isequal(largest_pit(x),9))

un1 = 2 un1 = 5 un1 = 6 un1 = 6 un1 = 7 un1 = 8 un1 = 0 10 un1 = 0 10 un1 = 0 12 un1 = 0 12 un1 = 0 12 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 14 un1 = 0 12 un1 = 15 un1 = 0 12 un1 = 0 15 un1 = 17 un1 = 0 12 un1 = 0 16 un1 = 0 15 un1 = 0 15 un1 = 0 16 un1 = 0 16 un1 = 0 15 un1 = 0 15 un1 = 20 un1 = 0 16 un1 = 0 16 un1 = 0 15 un1 = 0 19 un1 = 20 un1 = 20 un1 = 0 15 un1 = 0 19 un1 = 0 19 un1 = 0 19 un1 = 0 19 g = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 h = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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2 9 6 2 1 6 4 1 1 y = 9

16   Pass
x = [ 0 0 0 0 0 0 1 1 0 0 1 0 1 0 0 0 0 0 0 1 0 1 0 1 1 0 0 0 0 0 0 1 1 0 0 1 0 1 0 0 0 0 0 0 0 1 0 0 1 0 1 0 1 0 0 1 1 0 0 0 0 1 0 1 0 1 0 0 0 1 0 0 0 0 1 0 1 0 0 0 1 0 1 0 0 1 0 0 1 0 1 1 0 0 0 0 1 0 0 1 0 1 0 0 1 0 1 1 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 1 1 0 0 1 0 0 1 0 1 0 0 0 0 1 0 0 0 1 0 1 1 0 0 0 0 0 0 0 0 1 0 1 0 1 1 1 0 1 0 0 0 0 0 0 1 0 0 0 1 0 0 1 0 0 1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 1 0 1 1 1 0 1 0 1 0 0 1 1 0 0 0 1 1 0 0]; assert(isequal(largest_pit(x),16))

un1 = 0 1 un = 0 1 4 un = 1 4 un = 0 2 5 un = 2 5 un1 = 6 un1 = 0 7 un1 = 0 6 un1 = 0 6 un1 = 0 7 un1 = 0 7 un1 = 0 6 un1 = 0 6 un1 = 8 un1 = 0 7 un1 = 0 7 un1 = 0 6 un1 = 0 8 un1 = 0 7 un1 = 0 6 un1 = 0 8 un1 = 0 9 un1 = 0 7 un1 = 0 7 un = 6 10 un = 6 10 un1 = 0 8 un1 = 0 8 un1 = 0 9 un1 = 0 7 un1 = 0 7 un1 = 0 8 un1 = 0 9 un1 = 12 un1 = 13 un1 = 0 12 un1 = 0 12 un = 0 12 14 un = 12 14 un1 = 0 17 un1 = 0 17 un1 = 0 17 un1 = 0 17 un1 = 0 17 un1 = 0 18 un1 = 0 17 un = 17 19 un = 17 19 un1 = 0 22 un1 = 0 18 un1 = 0 20 un1 = 0 21 un1 = 0 22 un1 = 0 22 un1 = 0 22 un1 = 0 18 un1 = 0 20 un1 = 23 un = 0 21 22 un = 21 22 un1 = 0 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un = 0 8 9 un = 8 9 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 11 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 10 un1 = 0 10 un = 10 11 un = 10 11 un1 = 12 un1 = 0 12 un1 = 0 12 un1 = 0 12 un1 = 0 12 un1 = 0 12 un1 = 0 12 un1 = 0 12 g = 1 3 5 12 h = 0 0 0 0 h = 4 0 0 0 h = 4 4 0 0 h = 4 4 2 0 h = 4 4 2 104 y = 104

20   Pass
x = [ 0 0 1 1 1 0 0 1 0 1 0 0 1 0 1 1 1 1 1 0 0 1 0 0 0 1 1 1 1 1 1 1 0 1 1 0 0 0 1 1 1 1 0 1 1 1 1 0 1 0 0 0 1 1 0 1 0 1 1 0 1 0 0 1 1 1 1 0 1 1 1 1 0 1 0 1 1 1 1 0 1 1 0 1 0 1 1 1 0 0 0 0 0 0 0 0 0 1 0 1 1 1 1 0 1 0 0 0 0 1 1 0 1 1 1 1 0 1 0 1 0 0 0 1 0 1 0 1 0 0 0 0 1 1 1 0 0 1 0 1 0 0 1 1 1 0 1 1 0 0 0 1 0 1 0 0 0 0 1 0 0 0 0 1 0 0 1 1 0 1 0 1 1 0 1 0 1 0 0 0 0 1 0 0 0 1 1 0 0 1 0 0 1 1 0 0 1 1 1 1 1 1 0 1 0 1 1 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 1 1 0 1 1 0 0 1 1 1 0 0 0 0 1 0 0 0 1 1 0 0 0 0 1 1 1 1 0 1 0 0 0 1 1 0 1 1 1 0 1 1 0 0 0 0 0 0 0 1 1 1 0 1 1 0 1 1 1 1 1 1 1 0 1 1 1 0 1 1 1 0 1 0 1 1 0 0 1 0 0 0 0 1 1 0 0 1 0 1 0 0 1 1 0 1 0 0 1 0 1 0 0 0 0 1 1 1 1 0 1 1 0 0 0 0 0 1]; assert(isequal(largest_pit(x),158))

un1 = 0 1 un1 = 0 1 un1 = 0 2 un1 = 0 3 un1 = 0 3 un1 = 0 3 un1 = 0 1 un1 = 0 1 un1 = 0 1 un1 = 0 2 un1 = 0 2 un = 0 2 3 un = 2 3 un1 = 0 4 un1 = 0 4 un1 = 0 4 un1 = 0 4 un1 = 0 4 un1 = 0 1 un1 = 0 1 un1 = 0 1 un1 = 0 1 un = 0 1 4 un = 1 4 un1 = 0 5 un1 = 0 5 un1 = 0 5 un1 = 0 5 un1 = 0 5 un1 = 0 5 un1 = 0 5 un1 = 0 5 un1 = 0 5 un1 = 0 5 un1 = 0 5 un1 = 0 5 un1 = 0 5 un1 = 0 5 un1 = 0 5 un1 = 0 5 un1 = 0 5 un1 = 0 5 un1 = 0 5 un1 = 0 5 un1 = 0 5 un1 = 0 5 un1 = 0 5 un1 = 0 5 un1 = 0 5 un1 = 0 5 un1 = 0 5 un1 = 0 5 un1 = 0 5 un1 = 0 5 un1 = 0 5 un1 = 0 5 un1 = 0 5 un1 = 0 5 un1 = 0 5 un1 = 0 5 un1 = 6 un = 0 5 7 un = 5 7 un1 = 0 8 un1 = 0 8 un1 = 0 8 un1 = 0 8 un1 = 0 6 un1 = 0 6 un1 = 0 8 un1 = 0 8 un1 = 0 8 un1 = 0 8 un1 = 9 un1 = 0 6 un1 = 0 6 un1 = 0 6 un1 = 10 un1 = 0 8 un1 = 0 8 un1 = 0 6 un1 = 0 10 un = 0 8 11 un = 8 11 un1 = 0 12 un1 = 0 12 un1 = 0 12 un1 = 0 6 un1 = 0 6 un1 = 0 10 un1 = 0 12 un1 = 0 12 un1 = 0 12 un1 = 0 6 un1 = 0 6 un = 0 10 13 un = 10 13 un1 = 0 14 un1 = 0 14 un1 = 0 14 un = 0 12 14 un = 12 14 un1 = 0 15 un1 = 0 15 un1 = 0 15 un1 = 0 6 un1 = 0 15 un1 = 0 15 un1 = 0 15 un1 = 0 6 un1 = 0 6 un1 = 0 15 un1 = 0 15 un1 = 0 15 un1 = 0 15 un = 0 6 15 un = 6 15 un1 = 0 17 un1 = 0 17 un1 = 0 17 un1 = 0 17 un = 17 19 un = 17 19 un1 = 0 20 un1 = 0 20 un1 = 0 20 un1 = 0 20 un1 = 0 20 un1 = 0 20 un1 = 0 20 un1 = 0 20 un1 = 0 20 un1 = 0 20 un1 = 0 20 un1 = 0 20 un1 = 0 20 un1 = 0 20 un1 = 0 20 un1 = 0 20 un1 = 0 21 un1 = 0 21 un1 = 0 21 un1 = 0 20 un1 = 0 20 un1 = 0 20 un1 = 0 20 un1 = 0 20 un1 = 0 20 un1 = 0 20 un1 = 0 21 un1 = 0 20 un1 = 0 20 un1 = 0 20 un1 = 0 20 un1 = 0 20 un1 = 0 20 un1 = 0 21 un1 = 0 20 un1 = 0 20 un1 = 0 20 un1 = 0 20 un1 = 0 20 un1 = 0 20 un1 = 0 21 g = 9 16 18 20 21 22 h = 0 0 0 0 0 0 h = 2 0 0 0 0 0 h = 2 1 0 0 0 0 h = 2 1 1 0 0 0 h = 2 1 1 158 0 0 h = 2 1 1 158 7 0 h = 2 1 1 158 7 1 y = 158

### Community Treasure Hunt

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

Start Hunting!