Cody

# Problem 54. Maximum running product for a string of numbers

Solution 245068

Submitted on 16 May 2013 by chen
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))

pp = 120 pp = 480 pp = 720 pp = 480 pp = 120

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

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

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

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

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

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

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

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

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

pp = 1