Cody

Problem 84. Longest Divisor Run

Solution 2615245

Submitted on 26 Jun 2020 by 春樹 内糸
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 14 93 1147 473 259 629 1591 851 533 2021 86 817 2279 1763 961 Columns 15 through 16 1073 205 n = 16 len = 1 d = 1 v = 93 fs = 3 31 p = 3 idx = 2 p = 31 idx = 2 idx = 3 len = 2 d = 31 v = 1147 fs = 31 37 p = 31 idx = 3 p = 37 idx = 3 v = 473 fs = 11 43 p = 11 idx = 4 p = 43 idx = 4 v = 259 fs = 7 37 p = 7 idx = 5 p = 37 idx = 5 idx = 6 idx = 7 idx = 8 len = 4 d = 37 v = 629 fs = 17 37 p = 17 idx = 6 p = 37 idx = 6 idx = 7 idx = 8 v = 1591 fs = 37 43 p = 37 idx = 7 idx = 8 p = 43 idx = 7 v = 851 fs = 23 37 p = 23 idx = 8 p = 37 idx = 8 v = 533 fs = 13 41 p = 13 idx = 9 p = 41 idx = 9 v = 2021 fs = 43 47 p = 43 idx = 10 idx = 11 idx = 12 idx = 13 idx = 14 len = 5 d = 43 p = 47 idx = 10 v = 86 fs = 2 43 p = 2 idx = 11 p = 43 idx = 11 idx = 12 idx = 13 idx = 14 v = 817 fs = 19 43 p = 19 idx = 12 p = 43 idx = 12 idx = 13 idx = 14 v = 2279 fs = 43 53 p = 43 idx = 13 idx = 14 p = 53 idx = 13 v = 1763 fs = 41 43 p = 41 idx = 14 p = 43 idx = 14 v = 961 fs = 31 p = 31 idx = 15 v = 1073 fs = 29 37 p = 29 idx = 16 p = 37 idx = 16 v = 205 fs = 5 41 p = 5 idx = 17 p = 41 idx = 17

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

n = 8 len = 1 d = 1 v = 166 fs = 2 83 p = 2 idx = 2 p = 83 idx = 2 v = 553 fs = 7 79 p = 7 idx = 3 p = 79 idx = 3 v = 1241 fs = 17 73 p = 17 idx = 4 p = 73 idx = 4 v = 869 fs = 11 79 p = 11 idx = 5 p = 79 idx = 5 idx = 6 idx = 7 len = 3 d = 79 v = 237 fs = 3 79 p = 3 idx = 6 p = 79 idx = 6 idx = 7 v = 395 fs = 5 79 p = 5 idx = 7 p = 79 idx = 7 v = 1079 fs = 13 83 p = 13 idx = 8 p = 83 idx = 8 idx = 9 v = 1577 fs = 19 83 p = 19 idx = 9 p = 83 idx = 9

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

n = 7 len = 1 d = 1 v = 533 fs = 13 41 p = 13 idx = 2 p = 41 idx = 2 idx = 3 idx = 4 idx = 5 idx = 6 idx = 7 idx = 8 len = 7 d = 41 v = 205 fs = 5 41 p = 5 idx = 3 p = 41 idx = 3 idx = 4 idx = 5 idx = 6 idx = 7 idx = 8 v = 123 fs = 3 41 p = 3 idx = 4 p = 41 idx = 4 idx = 5 idx = 6 idx = 7 idx = 8 v = 287 fs = 7 41 p = 7 idx = 5 p = 41 idx = 5 idx = 6 idx = 7 idx = 8 v = 451 fs = 11 41 p = 11 idx = 6 p = 41 idx = 6 idx = 7 idx = 8 v = 697 fs = 17 41 p = 17 idx = 7 p = 41 idx = 7 idx = 8 v = 82 fs = 2 41 p = 2 idx = 8 p = 41 idx = 8

4   Pass
a = [3937 7493 1397 5633 6439 3151 5617 685 7261 5069 ... 959 3973 411 2603 2329 1781 262]; len_correct = 12; d_correct = 137; [len,d] = divisor_run(a); assert(isequal(len,len_correct) && isequal(d,d_correct))

n = 17 len = 1 d = 1 v = 3937 fs = 31 127 p = 31 idx = 2 p = 127 idx = 2 idx = 3 idx = 4 len = 3 d = 127 v = 7493 fs = 59 127 p = 59 idx = 3 p = 127 idx = 3 idx = 4 v = 1397 fs = 11 127 p = 11 idx = 4 p = 127 idx = 4 v = 5633 fs = 43 131 p = 43 idx = 5 p = 131 idx = 5 v = 6439 fs = 47 137 p = 47 idx = 6 p = 137 idx = 6 idx = 7 idx = 8 idx = 9 idx = 10 idx = 11 idx = 12 idx = 13 idx = 14 idx = 15 idx = 16 idx = 17 len = 12 d = 137 v = 3151 fs = 23 137 p = 23 idx = 7 p = 137 idx = 7 idx = 8 idx = 9 idx = 10 idx = 11 idx = 12 idx = 13 idx = 14 idx = 15 idx = 16 idx = 17 v = 5617 fs = 41 137 p = 41 idx = 8 p = 137 idx = 8 idx = 9 idx = 10 idx = 11 idx = 12 idx = 13 idx = 14 idx = 15 idx = 16 idx = 17 v = 685 fs = 5 137 p = 5 idx = 9 p = 137 idx = 9 idx = 10 idx = 11 idx = 12 idx = 13 idx = 14 idx = 15 idx = 16 idx = 17 v = 7261 fs = 53 137 p = 53 idx = 10 p = 137 idx = 10 idx = 11 idx = 12 idx = 13 idx = 14 idx = 15 idx = 16 idx = 17 v = 5069 fs = 37 137 p = 37 idx = 11 p = 137 idx = 11 idx = 12 idx = 13 idx = 14 idx = 15 idx = 16 idx = 17 v = 959 fs = 7 137 p = 7 idx = 12 p = 137 idx = 12 idx = 13 idx = 14 idx = 15 idx = 16 idx = 17 v = 3973 fs = 29 137 p = 29 idx = 13 p = 137 idx = 13 idx = 14 idx = 15 idx = 16 idx = 17 v = 411 fs = 3 137 p = 3 idx = 14 p = 137 idx = 14 idx = 15 idx = 16 idx = 17 v = 2603 fs = 19 137 p = 19 idx = 15 p = 137 idx = 15 idx = 16 idx = 17 v = 2329 fs = 17 137 p = 17 idx = 16 p = 137 idx = 16 idx = 17 v = 1781 fs = 13 137 p = 13 idx = 17 p = 137 idx = 17 v = 262 fs = 2 131 p = 2 idx = 18 p = 131 idx = 18

Suggested Problems

More from this Author95

Community Treasure Hunt

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

Start Hunting!