Cody

Problem 54. Maximum running product for a string of numbers

Solution 154490

Submitted on 26 Oct 2012 by J.R.! Menzinger
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 = 120 480 720 480 120

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

s = Columns 1 through 5 0 0 0 0 9072 Columns 6 through 10 4032 2880 6480 1440 1080 Columns 11 through 15 0 0 0 0 0 Columns 16 through 20 1344 0 0 0 0 Columns 21 through 25 0 1152 0 0 0 Columns 26 through 30 0 0 31104 7776 6912 Columns 31 through 35 0 0 0 0 0 Columns 36 through 40 960 960 960 240 120 Columns 41 through 45 24 56 0 0 0

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

s = Columns 1 through 5 180 360 540 2700 1620 Columns 6 through 10 900 3600 5400 7560 22680 Columns 11 through 15 13608 3402 1134 1296 576 Columns 16 through 20 1152 1152 2304 1152 864 Columns 21 through 25 432 1728 864 432 1008 Columns 26 through 30 3024 1890 0 0 0 Columns 31 through 35 0 0 512 2304 2016 Columns 36 through 40 252 378 3402 1134 1458 Columns 41 through 45 13122 6561 6561 19683 19683 Columns 46 through 47 19683 59049

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

s = Columns 1 through 5 1008 720 180 420 420 Columns 6 through 10 140 0 0 0 0 Columns 11 through 15 0 0 0 0 1080 Columns 16 through 20 480 3840 4800 5760 5760 Columns 21 through 25 12960 3240 1944 1296 1296 Columns 26 through 30 0 0 0 0 0 Columns 31 through 35 576 0 0 0 0 Columns 36 through 40 0 480 720 864 864 Columns 41 through 45 2304 2304 384 192 144 Columns 46 through 50 162 243 1458 0 0 Columns 51 through 54 0 0 0 0

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

s = Columns 1 through 5 0 0 0 0 0 Columns 6 through 10 0 450 600 1600 1600 Columns 11 through 15 2240 1792 1792 1792 1792 Columns 16 through 20 1280 640 0 0 0 Columns 21 through 25 0 0 0 0 0 Columns 26 through 30 1728 1728 576 1440 720 Columns 31 through 35 0 0 0 0 0 Columns 36 through 40 315 105 630 360 1080 Columns 41 through 45 1296 3024 4032 9072 6048 Columns 46 through 50 5040 6480 0 0 0 Columns 51 through 55 0 0 0 0 0 Columns 56 through 60 0 0 0 0 0 Columns 61 through 64 0 0 0 0

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

s = 1