Cody

# Problem 84. Longest Divisor Run

Solution 719269

Submitted on 21 Aug 2015 by Ian Riley
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
%% a = [93 1147 473 259 629 1591 851 533 2021 86 817 2279 1763 961 1073 205] len_correct = 5; d_correct = 43; [len,d] = divisor_run(a); assert(isequal(len,len_correct) && isequal(d,d_correct))

a = Columns 1 through 8 93 1147 473 259 629 1591 851 533 Columns 9 through 16 2021 86 817 2279 1763 961 1073 205 divs = 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 divs = 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 divs = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 divs = 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 divs = 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 divs = 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 div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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 divs = 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 divs = ...

2   Pass
%% a = [166 553 1241 869 237 395 1079 1577]; len_correct = 3; d_correct = 79; [len,d] = divisor_run(a); assert(isequal(len,len_correct) && isequal(d,d_correct))

divs = 1 0 0 0 0 0 0 0 divs = 0 0 0 0 1 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 1 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 1 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 1 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 1 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 1 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 1 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 1 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 1 0 1 1 1 0 0 d = 79 len = 3 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 1 0 0 0 0 0 1 1 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 1 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 0 divs = ...

3   Fail
%% a = [533 205 123 287 451 697 82]; len_correct = 7; d_correct = 41; [len,d] = divisor_run(a); assert(isequal(len,len_correct) && isequal(d,d_correct))

divs = 0 0 0 0 0 0 1 divs = 0 0 1 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 1 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 1 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 1 0 0 divs = 0 0 0 0 0 0 0 divs = 1 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 1 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 1 1 1 1 1 1 1 d = 41 len = 3 d = 41 len = 4 d = 41 len = 5 d = 41 len = 6 d = 41 len = 7 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0 0 0 0 0 divs = 0 0 0