Cody

Problem 54. Maximum running product for a string of numbers

Solution 1909935

Submitted on 23 Aug 2019 by Abbie Lund
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
s = '123454321'; i_correct = 3; assert(isequal(running_product(s),i_correct))

s = 1 2 3 4 5 4 3 2 1 yold = 0 y = 120 i = 1 yold = 120 y = 480 i = 2 yold = 480 y = 720 i = 3 yold = 720 y = 480 y = 120

2   Pass
s = '5820974944592307816406286208998628034825342117067'; i_correct = 28; assert(isequal(running_product(s),i_correct))

s = Columns 1 through 30 5 8 2 0 9 7 4 9 4 4 5 9 2 3 0 7 8 1 6 4 0 6 2 8 6 2 0 8 9 9 Columns 31 through 49 8 6 2 8 0 3 4 8 2 5 3 4 2 1 1 7 0 6 7 yold = 0 y = 0 y = 0 y = 0 y = 0 y = 9072 i = 5 yold = 9072 y = 4032 y = 2880 y = 6480 y = 1440 y = 1080 y = 0 y = 0 y = 0 y = 0 y = 0 y = 1344 y = 0 y = 0 y = 0 y = 0 y = 0 y = 1152 y = 0 y = 0 y = 0 y = 0 y = 0 y = 31104 i = 28 yold = 31104 y = 7776 y = 6912 y = 0 y = 0 y = 0 y = 0 y = 0 y = 960 y = 960 y = 960 y = 240 y = 120 y = 24 y = 56 y = 0 y = 0 y = 0

3   Pass
s = '141592653589793238462643383279502884197169399399999'; i_correct = 47; assert(isequal(running_product(s),i_correct))

s = Columns 1 through 30 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 Columns 31 through 51 5 0 2 8 8 4 1 9 7 1 6 9 3 9 9 3 9 9 9 9 9 yold = 0 y = 180 i = 1 yold = 180 y = 360 i = 2 yold = 360 y = 540 i = 3 yold = 540 y = 2700 i = 4 yold = 2700 y = 1620 y = 900 y = 3600 i = 7 yold = 3600 y = 5400 i = 8 yold = 5400 y = 7560 i = 9 yold = 7560 y = 22680 i = 10 yold = 22680 y = 13608 y = 3402 y = 1134 y = 1296 y = 576 y = 1152 y = 1152 y = 2304 y = 1152 y = 864 y = 432 y = 1728 y = 864 y = 432 y = 1008 y = 3024 y = 1890 y = 0 y = 0 y = 0 y = 0 y = 0 y = 512 y = 2304 y = 2016 y = 252 y = 378 y = 3402 y = 1134 y = 1458 y = 13122 y = 6561 y = 6561 y = 19683 y = 19683 y = 19683 y = 59049 i = 47 yold = 59049

4   Pass
s = '7831652712019091456485669234603486104543266482133936072602'; i_correct = 21; assert(isequal(running_product(s),i_correct))

s = Columns 1 through 30 7 8 3 1 6 5 2 7 1 2 0 1 9 0 9 1 4 5 6 4 8 5 6 6 9 2 3 4 6 0 Columns 31 through 58 3 4 8 6 1 0 4 5 4 3 2 6 6 4 8 2 1 3 3 9 3 6 0 7 2 6 0 2 yold = 0 y = 1008 i = 1 yold = 1008 y = 720 y = 180 y = 420 y = 420 y = 140 y = 0 y = 0 y = 0 y = 0 y = 0 y = 0 y = 0 y = 0 y = 1080 i = 15 yold = 1080 y = 480 y = 3840 i = 17 yold = 3840 y = 4800 i = 18 yold = 4800 y = 5760 i = 19 yold = 5760 y = 5760 y = 12960 i = 21 yold = 12960 y = 3240 y = 1944 y = 1296 y = 1296 y = 0 y = 0 y = 0 y = 0 y = 0 y = 576 y = 0 y = 0 y = 0 y = 0 y = 0 y = 480 y = 720 y = 864 y = 864 y = 2304 y = 2304 y = 384 y = 192 y = 144 y = 162 y = 243 y = 1458 y = 0 y = 0 y = 0 y = 0 y = 0 y = 0

5   Pass
s = '70066063155881748815209209628292540917153643678925903600113305305488'; i_correct = 44; assert(isequal(running_product(s),i_correct))

s = Columns 1 through 30 7 0 0 6 6 0 6 3 1 5 5 8 8 1 7 4 8 8 1 5 2 0 9 2 0 9 6 2 8 2 Columns 31 through 60 9 2 5 4 0 9 1 7 1 5 3 6 4 3 6 7 8 9 2 5 9 0 3 6 0 0 1 1 3 3 Columns 61 through 68 0 5 3 0 5 4 8 8 yold = 0 y = 0 y = 0 y = 0 y = 0 y = 0 y = 0 y = 450 i = 7 yold = 450 y = 600 i = 8 yold = 600 y = 1600 i = 9 yold = 1600 y = 1600 y = 2240 i = 11 yold = 2240 y = 1792 y = 1792 y = 1792 y = 1792 y = 1280 y = 640 y = 0 y = 0 y = 0 y = 0 y = 0 y = 0 y = 0 y = 0 y = 1728 y = 1728 y = 576 y = 1440 y = 720 y = 0 y = 0 y = 0 y = 0 y = 0 y = 315 y = 105 y = 630 y = 360 y = 1080 y = 1296 y = 3024 i = 42 yold = 3024 y = 4032 i = 43 yold = 4032 y = 9072 i = 44 yold = 9072 y = 6048 y = 5040 y = 6480 y = 0 y = 0 y = 0 y = 0 y = 0 y = 0 y = 0 y = 0 y = 0 y = 0 y = 0 y = 0 y = 0 y = 0 y = 0 y = 0 y = 0

6   Pass
s = '11111'; i_correct = 1; assert(isequal(running_product(s),i_correct))

s = 1 1 1 1 1 yold = 0 y = 1 i = 1 yold = 1