Cody

Problem 84. Longest Divisor Run

Solution 1531403

Submitted on 17 May 2018 by Ryan Mitchell
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 ans = 93 1147 commonD = 31 len = 2 d = 31 ans = 93 1147 473 commonD = 1 ans = 93 1147 473 259 commonD = 1 ans = 93 1147 473 259 629 commonD = 1 ans = 93 1147 473 259 629 1591 commonD = 1 ans = 93 1147 473 259 629 1591 851 commonD = 1 ans = 93 1147 473 259 629 1591 851 533 commonD = 1 ans = 93 1147 473 259 629 1591 851 533 2021 commonD = 1 ans = 93 1147 473 259 629 1591 851 533 2021 86 commonD = 1 ans = 93 1147 473 259 629 1591 851 533 2021 86 817 commonD = 1 ans = 93 1147 473 259 629 1591 851 533 2021 86 817 2279 commonD = 1 ans = 93 1147 473 259 629 1591 851 533 2021 86 817 2279 1763 commonD = 1 ans = 93 1147 473 259 629 1591 851 533 2021 86 817 2279 1763 961 commonD = 1 ans = Columns 1 through 14 93 1147 473 259 629 1591 851 533 2021 86 817 2279 1763 961 Column 15 1073 commonD = 1 ans = Columns 1 through 14 93 1147 473 259 629 1591 851 533 2021 86 817 2279 1763 961 Columns 15 through 16 1073 205 commonD = 1 ans = 1147 473 commonD = 1 ans = 1147 473 259 commonD = 1 ans = 1147 473 259 629 commonD = 1 ans = 1147 473 259 629 1591 commonD = 1 ans = 1147 473 259 629 1591 851 commonD = 1 ans = 1147 473 259 629 1591 851 533 commonD = 1 ans = 1147 473 259 629 1591 851 533 2021 commonD = 1 ans = 1147 473 259 629 1591 851 533 2021 86 commonD = 1 ans = 1147 473 259 629 1591 851 533 2021 86 817 commonD = 1 ans = 1147 473 259 629 1591 851 533 2021 86 817 2279 commonD = 1 ans = 1147 473 259 629 1591 851 533 2021 86 817 2279 1763 commonD = 1 ans = 1147 473 259 629 1591 851 533 2021 86 817 2279 1763 961 commonD = 1 ans = 1147 473 259 629 1591 851 533 2021 86 817 2279 1763 961 1073 commonD = 1 ans = Columns 1 through 14 1147 473 259 629 1591 851 533 2021 86 817 2279 1763 961 1073 Column 15 205 commonD = 1 ans = 473 259 commonD = 1 ans = 473 259 629 commonD = 1 ans = 473 259 629 1591 commonD = 1 ans = 473 259 629 1591 851 commonD = 1 ans = 473 259 629 1591 851 533 commonD = 1 ans = 473 259 629 1591 851 533 2021 commonD = 1 ans = 473 259 629 1591 851 533 2021 86 commonD = 1 ans = 473 259 629 1591 851 533 2021 86 817 commonD = 1 ans = 473 259 629 1591 851 533 2021 86 817 2279 commonD = 1 ans = 473 259 629 1591 851 533 2021 86 817 2279 1763 commonD = 1 ans = 473 259 629 1591 851 533 2021 86 817 2279 1763 961 commonD = 1 ans = 473 259 629 1591 851 533 2021 86 817 2279 1763 961 1073 commonD = 1 ans = 473 259 629 1591 851 533 2021 86 817 2279 1763 961 1073 205 commonD = 1 ans = 259 629 commonD = 37 len = 2 d = 37 ans = 259 629 1591 commonD = 37 len = 3 d = 37 ans = 259 629 1591 851 commonD = 37 len = 4 d = 37 ans = 259 629 1591 851 533 commonD = 1 ans = 259 629 1591 851 533 2021 commonD = 1 ans = 259 629 1591 851 533 2021 86 commonD = 1 ans = 259 629 1591 851 533 2021 86 817 commonD = 1 ans = 259 629 1591 851 533 2021 86 817 2279 commonD = 1 ans = 259 629 1591 851 533 2021 86 817 2279 1763 commonD = 1 ans = 259 629 1591 851 533 2021 86 817 2279 1763 961 commonD = 1 ans = 259 629 1591 851 533 2021 86 817 2279 1763 961 1073 commonD = 1 ans = 259 629 1591 851 533 2021 86 817 2279 1763 961 1073 205 commonD = 1 ans = 629 1591 commonD = 37 ans = 629 1591 851 commonD = 37 ans = 629 1591 851 533 commonD = 1 ans = 629 1591 851 533 2021 commonD = 1 ans = 629 1591 851 533 2021 86 commonD = 1 ans = 629 1591 851 533 2021 86 817 commonD = 1 ans = 629 1591 851 533 2021 86 817 2279 commonD = 1 ans = 629 1591 851 533 2021 86 817 2279 1763 commonD = 1 ans = 629 1591 851 533 2021 86 817 2279 1763 961 commonD = 1 ans = 629 1591 851 533 2021 86 817 2279 1763 961 1073 commonD = 1 ans = 629 1591 851 533 2021 86 817 2279 1763 961 1073 205 commonD = 1 ans = 1591 851 commonD = 37 ans = 1591 851 533 commonD = 1 ans = 1591 851 533 2021 commonD = 1 ans = 1591 851 533 2021 86 commonD = 1 ans = 1591 851 533 2021 86 817 commonD = 1 ans = 1591 851 533 2021 86 817 2279 commonD = 1 ans = 1591 851 533 2021 86 817 2279 1763 commonD = 1 ans = 1591 851 533 2021 86 817 2279 1763 961 commonD = 1 ans = 1591 851 533 2021 86 817 2279 1763 961 1073 commonD = 1 ans = 1591 851 533 2021 86 817 2279 1763 961 1073 205 commonD = 1 ans = 851 533 commonD = 1 ans = 851 533 2021 commonD = 1 ans = 851 533 2021 86 commonD = 1 ans = 851 ...

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

ans = 166 553 commonD = 1 ans = 166 553 1241 commonD = 1 ans = 166 553 1241 869 commonD = 1 ans = 166 553 1241 869 237 commonD = 1 ans = 166 553 1241 869 237 395 commonD = 1 ans = 166 553 1241 869 237 395 1079 commonD = 1 ans = 166 553 1241 869 237 395 1079 1577 commonD = 1 ans = 553 1241 commonD = 1 ans = 553 1241 869 commonD = 1 ans = 553 1241 869 237 commonD = 1 ans = 553 1241 869 237 395 commonD = 1 ans = 553 1241 869 237 395 1079 commonD = 1 ans = 553 1241 869 237 395 1079 1577 commonD = 1 ans = 1241 869 commonD = 1 ans = 1241 869 237 commonD = 1 ans = 1241 869 237 395 commonD = 1 ans = 1241 869 237 395 1079 commonD = 1 ans = 1241 869 237 395 1079 1577 commonD = 1 ans = 869 237 commonD = 79 len = 2 d = 79 ans = 869 237 395 commonD = 79 len = 3 d = 79 ans = 869 237 395 1079 commonD = 1 ans = 869 237 395 1079 1577 commonD = 1 ans = 237 395 commonD = 79 ans = 237 395 1079 commonD = 1 ans = 237 395 1079 1577 commonD = 1 ans = 395 1079 commonD = 1 ans = 395 1079 1577 commonD = 1 ans = 1079 1577 commonD = 83

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

ans = 533 205 commonD = 41 len = 2 d = 41 ans = 533 205 123 commonD = 41 len = 3 d = 41 ans = 533 205 123 287 commonD = 41 len = 4 d = 41 ans = 533 205 123 287 451 commonD = 41 len = 5 d = 41 ans = 533 205 123 287 451 697 commonD = 41 len = 6 d = 41 ans = 533 205 123 287 451 697 82 commonD = 41 len = 7 d = 41 ans = 205 123 commonD = 41 ans = 205 123 287 commonD = 41 ans = 205 123 287 451 commonD = 41 ans = 205 123 287 451 697 commonD = 41 ans = 205 123 287 451 697 82 commonD = 41 ans = 123 287 commonD = 41 ans = 123 287 451 commonD = 41 ans = 123 287 451 697 commonD = 41 ans = 123 287 451 697 82 commonD = 41 ans = 287 451 commonD = 41 ans = 287 451 697 commonD = 41 ans = 287 451 697 82 commonD = 41 ans = 451 697 commonD = 41 ans = 451 697 82 commonD = 41 ans = 697 82 commonD = 41

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

ans = 3937 7493 commonD = 127 len = 2 d = 127 ans = 3937 7493 1397 commonD = 127 len = 3 d = 127 ans = 3937 7493 1397 5633 commonD = 1 ans = 3937 7493 1397 5633 6439 commonD = 1 ans = 3937 7493 1397 5633 6439 3151 commonD = 1 ans = 3937 7493 1397 5633 6439 3151 5617 commonD = 1 ans = 3937 7493 1397 5633 6439 3151 5617 685 commonD = 1 ans = 3937 7493 1397 5633 6439 3151 5617 685 7261 commonD = 1 ans = 3937 7493 1397 5633 6439 3151 5617 685 7261 5069 commonD = 1 ans = 3937 7493 1397 5633 6439 3151 5617 685 7261 5069 959 commonD = 1 ans = 3937 7493 1397 5633 6439 3151 5617 685 7261 5069 959 3973 commonD = 1 ans = 3937 7493 1397 5633 6439 3151 5617 685 7261 5069 959 3973 411 commonD = 1 ans = 3937 7493 1397 5633 6439 3151 5617 685 7261 5069 959 3973 411 2603 commonD = 1 ans = Columns 1 through 14 3937 7493 1397 5633 6439 3151 5617 685 7261 5069 959 3973 411 2603 Column 15 2329 commonD = 1 ans = Columns 1 through 14 3937 7493 1397 5633 6439 3151 5617 685 7261 5069 959 3973 411 2603 Columns 15 through 16 2329 1781 commonD = 1 ans = Columns 1 through 14 3937 7493 1397 5633 6439 3151 5617 685 7261 5069 959 3973 411 2603 Columns 15 through 17 2329 1781 262 commonD = 1 ans = 7493 1397 commonD = 127 ans = 7493 1397 5633 commonD = 1 ans = 7493 1397 5633 6439 commonD = 1 ans = 7493 1397 5633 6439 3151 commonD = 1 ans = 7493 1397 5633 6439 3151 5617 commonD = 1 ans = 7493 1397 5633 6439 3151 5617 685 commonD = 1 ans = 7493 1397 5633 6439 3151 5617 685 7261 commonD = 1 ans = 7493 1397 5633 6439 3151 5617 685 7261 5069 commonD = 1 ans = 7493 1397 5633 6439 3151 5617 685 7261 5069 959 commonD = 1 ans = 7493 1397 5633 6439 3151 5617 685 7261 5069 959 3973 commonD = 1 ans = 7493 1397 5633 6439 3151 5617 685 7261 5069 959 3973 411 commonD = 1 ans = 7493 1397 5633 6439 3151 5617 685 7261 5069 959 3973 411 2603 commonD = 1 ans = 7493 1397 5633 6439 3151 5617 685 7261 5069 959 3973 411 2603 2329 commonD = 1 ans = Columns 1 through 14 7493 1397 5633 6439 3151 5617 685 7261 5069 959 3973 411 2603 2329 Column 15 1781 commonD = 1 ans = Columns 1 through 14 7493 1397 5633 6439 3151 5617 685 7261 5069 959 3973 411 2603 2329 Columns 15 through 16 1781 262 commonD = 1 ans = 1397 5633 commonD = 1 ans = 1397 5633 6439 commonD = 1 ans = 1397 5633 6439 3151 commonD = 1 ans = 1397 5633 6439 3151 5617 commonD = 1 ans = 1397 5633 6439 3151 5617 685 commonD = 1 ans = 1397 5633 6439 3151 5617 685 7261 commonD = 1 ans = 1397 5633 6439 3151 5617 685 7261 5069 commonD = 1 ans = 1397 5633 6439 3151 5617 685 7261 5069 959 commonD = 1 ans = 1397 5633 6439 3151 5617 685 7261 5069 959 3973 commonD = 1 ans = 1397 5633 6439 3151 5617 685 7261 5069 959 3973 411 commonD = 1 ans = 1397 5633 6439 3151 5617 685 7261 5069 959 3973 411 2603 commonD = 1 ans = 1397 5633 6439 3151 5617 685 7261 5069 959 3973 411 2603 2329 commonD = 1 ans = 1397 5633 6439 3151 5617 685 7261 5069 959 3973 411 2603 2329 1781 commonD = 1 ans = Columns 1 through 14 1397 5633 6439 3151 5617 685 7261 5069 959 3973 411 2603 2329 1781 Column 15 262 commonD = 1 ans = 5633 6439 commonD = 1 ans = 5633 6439 3151 commonD = 1 ans = 5633 6439 3151 5617 commonD = 1 ans = 5633 6439 3151 5617 685 commonD = 1 ans = 5633 6439 3151 5617 685 7261 commonD = 1 ans = 5633 6439 3151 5617 685 7261 5069 commonD = 1 ans = 5633 6439 3151 5617 685 7261 5069 959 commonD = 1 ans = 5633 6439 3151 5617 685 7261 5069 959 3973 commonD = 1 ans = 5633 6439 3151 5617 685 7261 5069 959 3973 411 commonD = 1 ans = 5633 6439 3151 5617 685 7261 5069 959 3973 411 2603 commonD = 1 ans = 5633 6439 3151 5617 685 7261 5069 959 3973 411 2603 2329 commonD = 1 ans = 5633 6439 3151 5617 685 7261 5069 959 3973 411 2603 2329 1781 commonD = 1 ans = 5633 6439 3151 5617 685 7261 5069 959 3973 411 2603 2329 1781 262 commonD = 1 ans = 6439 3151 commonD = 137 ans = 6439 3151 5617 commonD = 137 len = 3 d = 137 ans = 6439 3151 5617 685 commonD = 137 len = 4 d = 137 ans = 6439 3151 5617 685 7261 commonD = 137 len = 5 d = 137 ans = 6439 3151 5617 685 7261 5069 commonD = 137 len = 6 d = 137 ans = 6439 3151 5617 685 7261 5069 959 commonD = 137 len = 7 d = 137 ans = 6439 3151 5617 685 7261 5069 959 3973 commonD = 137 len = 8 d = 137 ans = 6439 3151 5617 685 7261 5069 959 3973 411 commonD = 137 len = 9 d = 137 ans = 6439 3151 5617 685 7261 5069 959 3973 411 2603 commonD = 137 len = 10 d = 137 ans = 6439 3151 5617 685 7261 5069 959 3973 411 2603 2329 commonD = 137 len = 11 d = 137 ans = 6439 3151 5617 685 7261 5069 959 3973 411 2603 2329 1781 commonD = 137 len = 12 d = 137 ans = 6439 3151 5617 685 7261 5069 959 3973 411 2603 2329 1781 262 commonD = 1 ans = 3151 5617 commonD = 137 ans = 3...

Community Treasure Hunt

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

Start Hunting!