Cody

Solution 2279545

Submitted on 14 May 2020 by Binbin Qi
  • Size: 39
  • This is the leading solution.
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 = fileread('largest_pit.m') assert(isempty(strfind(filetext, 'rand'))) assert(isempty(strfind(filetext, 'fileread'))) assert(isempty(strfind(filetext, 'assert')))

filetext = 'function ans = largest_pit(x) [r,c] = find(x); max(histcounts(conncomp(graph(max(abs(r-r'),abs(c-c'))<=1)))) end %This code written by profile_id 734801 '

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

ans = 1

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

ans = 0

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

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

ans = 27

10   Pass
x = zeros(14); assert(isequal(largest_pit(x),0))

ans = 0

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

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

ans = 8

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

ans = 3

14   Pass
x = [ 0 1 0 0 0 1 0 0 0 1 1 1 1 0 1 1 1 1 0 0 1 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 1 1 0 1 0 0 0 0 0 1 0 0 0 0 1 1 1 1 0 1 1 0 1 0 0 0 1 0 0 0 0 1 0 1 0 0 0 0 0 0 1 1 0 0 0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