Cody

Problem 54. Maximum running product for a string of numbers

Solution 2527421

Submitted on 12 Jun 2020 by Drake Madison
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))

test_prod = 480 test_prod = 720 test_prod = 480 test_prod = 120

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

test_prod = 0 test_prod = 0 test_prod = 0 test_prod = 9072 test_prod = 4032 test_prod = 2880 test_prod = 6480 test_prod = 1440 test_prod = 1080 test_prod = 0 test_prod = 0 test_prod = 0 test_prod = 0 test_prod = 0 test_prod = 1344 test_prod = 0 test_prod = 0 test_prod = 0 test_prod = 0 test_prod = 0 test_prod = 1152 test_prod = 0 test_prod = 0 test_prod = 0 test_prod = 0 test_prod = 0 test_prod = 31104 test_prod = 7776 test_prod = 6912 test_prod = 0 test_prod = 0 test_prod = 0 test_prod = 0 test_prod = 0 test_prod = 960 test_prod = 960 test_prod = 960 test_prod = 240 test_prod = 120 test_prod = 24 test_prod = 56 test_prod = 0 test_prod = 0 test_prod = 0

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

test_prod = 360 test_prod = 540 test_prod = 2700 test_prod = 1620 test_prod = 900 test_prod = 3600 test_prod = 5400 test_prod = 7560 test_prod = 22680 test_prod = 13608 test_prod = 3402 test_prod = 1134 test_prod = 1296 test_prod = 576 test_prod = 1152 test_prod = 1152 test_prod = 2304 test_prod = 1152 test_prod = 864 test_prod = 432 test_prod = 1728 test_prod = 864 test_prod = 432 test_prod = 1008 test_prod = 3024 test_prod = 1890 test_prod = 0 test_prod = 0 test_prod = 0 test_prod = 0 test_prod = 0 test_prod = 512 test_prod = 2304 test_prod = 2016 test_prod = 252 test_prod = 378 test_prod = 3402 test_prod = 1134 test_prod = 1458 test_prod = 13122 test_prod = 6561 test_prod = 6561 test_prod = 19683 test_prod = 19683 test_prod = 19683 test_prod = 59049

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

test_prod = 720 test_prod = 180 test_prod = 420 test_prod = 420 test_prod = 140 test_prod = 0 test_prod = 0 test_prod = 0 test_prod = 0 test_prod = 0 test_prod = 0 test_prod = 0 test_prod = 0 test_prod = 1080 test_prod = 480 test_prod = 3840 test_prod = 4800 test_prod = 5760 test_prod = 5760 test_prod = 12960 test_prod = 3240 test_prod = 1944 test_prod = 1296 test_prod = 1296 test_prod = 0 test_prod = 0 test_prod = 0 test_prod = 0 test_prod = 0 test_prod = 576 test_prod = 0 test_prod = 0 test_prod = 0 test_prod = 0 test_prod = 0 test_prod = 480 test_prod = 720 test_prod = 864 test_prod = 864 test_prod = 2304 test_prod = 2304 test_prod = 384 test_prod = 192 test_prod = 144 test_prod = 162 test_prod = 243 test_prod = 1458 test_prod = 0 test_prod = 0 test_prod = 0 test_prod = 0 test_prod = 0 test_prod = 0

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

test_prod = 0 test_prod = 0 test_prod = 0 test_prod = 0 test_prod = 0 test_prod = 450 test_prod = 600 test_prod = 1600 test_prod = 1600 test_prod = 2240 test_prod = 1792 test_prod = 1792 test_prod = 1792 test_prod = 1792 test_prod = 1280 test_prod = 640 test_prod = 0 test_prod = 0 test_prod = 0 test_prod = 0 test_prod = 0 test_prod = 0 test_prod = 0 test_prod = 0 test_prod = 1728 test_prod = 1728 test_prod = 576 test_prod = 1440 test_prod = 720 test_prod = 0 test_prod = 0 test_prod = 0 test_prod = 0 test_prod = 0 test_prod = 315 test_prod = 105 test_prod = 630 test_prod = 360 test_prod = 1080 test_prod = 1296 test_prod = 3024 test_prod = 4032 test_prod = 9072 test_prod = 6048 test_prod = 5040 test_prod = 6480 test_prod = 0 test_prod = 0 test_prod = 0 test_prod = 0 test_prod = 0 test_prod = 0 test_prod = 0 test_prod = 0 test_prod = 0 test_prod = 0 test_prod = 0 test_prod = 0 test_prod = 0 test_prod = 0 test_prod = 0 test_prod = 0 test_prod = 0

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

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!