Cody

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

Solution 41083

Submitted on 14 Feb 2012 by Josh
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))

x = 4 p = 120 p = 120 480 p = 120 480 720 p = 120 480 720 480 p = 120 480 720 480 120 i = 3

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

x = 4 p = 0 p = 0 0 p = 0 0 0 p = 0 0 0 0 p = 0 0 0 0 9072 p = Columns 1 through 5 0 0 0 0 9072 Column 6 4032 p = Columns 1 through 5 0 0 0 0 9072 Columns 6 through 7 4032 2880 p = Columns 1 through 5 0 0 0 0 9072 Columns 6 through 8 4032 2880 6480 p = Columns 1 through 5 0 0 0 0 9072 Columns 6 through 9 4032 2880 6480 1440 p = Columns 1 through 5 0 0 0 0 9072 Columns 6 through 10 4032 2880 6480 1440 1080 p = Columns 1 through 5 0 0 0 0 9072 Columns 6 through 10 4032 2880 6480 1440 1080 Column 11 0 p = Columns 1 through 5 0 0 0 0 9072 Columns 6 through 10 4032 2880 6480 1440 1080 Columns 11 through 12 0 0 p = Columns 1 through 5 0 0 0 0 9072 Columns 6 through 10 4032 2880 6480 1440 1080 Columns 11 through 13 0 0 0 p = Columns 1 through 5 0 0 0 0 9072 Columns 6 through 10 4032 2880 6480 1440 1080 Columns 11 through 14 0 0 0 0 p = 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 p = 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 Column 16 1344 p = 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 17 1344 0 p = 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 18 1344 0 0 p = 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 19 1344 0 0 0 p = 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 p = 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 Column 21 0 p = 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 22 0 1152 p = 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 23 0 1152 0 p = 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 24 0 1152 0 0 p = 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 p = 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 Column 26 0 p = 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 27 0 0 p = 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 28 0 0 31104 p = 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 29 0 0 31104 7776 p = 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 p = 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 Column 31 0 p = 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 32 0 0 p = 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 33 0 0 0 p = 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 ...

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

x = 4 p = 180 p = 180 360 p = 180 360 540 p = 180 360 540 2700 p = 180 360 540 2700 1620 p = Columns 1 through 5 180 360 540 2700 1620 Column 6 900 p = Columns 1 through 5 180 360 540 2700 1620 Columns 6 through 7 900 3600 p = Columns 1 through 5 180 360 540 2700 1620 Columns 6 through 8 900 3600 5400 p = Columns 1 through 5 180 360 540 2700 1620 Columns 6 through 9 900 3600 5400 7560 p = Columns 1 through 5 180 360 540 2700 1620 Columns 6 through 10 900 3600 5400 7560 22680 p = Columns 1 through 5 180 360 540 2700 1620 Columns 6 through 10 900 3600 5400 7560 22680 Column 11 13608 p = Columns 1 through 5 180 360 540 2700 1620 Columns 6 through 10 900 3600 5400 7560 22680 Columns 11 through 12 13608 3402 p = Columns 1 through 5 180 360 540 2700 1620 Columns 6 through 10 900 3600 5400 7560 22680 Columns 11 through 13 13608 3402 1134 p = Columns 1 through 5 180 360 540 2700 1620 Columns 6 through 10 900 3600 5400 7560 22680 Columns 11 through 14 13608 3402 1134 1296 p = 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 p = 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 Column 16 1152 p = 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 17 1152 1152 p = 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 18 1152 1152 2304 p = 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 19 1152 1152 2304 1152 p = 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 p = 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 Column 21 432 p = 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 22 432 1728 p = 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 23 432 1728 864 p = 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 24 432 1728 864 432 p = 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 p = 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 Column 26 3024 p = 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 27 3024 1890 p = 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 28 3024 1890 0 p = 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 29 3024 1890 0 0 p = 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 p = 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 Column 31 0 p = 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 32 0 0 p = 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 33 0 0 512 p = 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 1...

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

x = 4 p = 1008 p = 1008 720 p = 1008 720 180 p = 1008 720 180 420 p = 1008 720 180 420 420 p = Columns 1 through 5 1008 720 180 420 420 Column 6 140 p = Columns 1 through 5 1008 720 180 420 420 Columns 6 through 7 140 0 p = Columns 1 through 5 1008 720 180 420 420 Columns 6 through 8 140 0 0 p = Columns 1 through 5 1008 720 180 420 420 Columns 6 through 9 140 0 0 0 p = Columns 1 through 5 1008 720 180 420 420 Columns 6 through 10 140 0 0 0 0 p = Columns 1 through 5 1008 720 180 420 420 Columns 6 through 10 140 0 0 0 0 Column 11 0 p = Columns 1 through 5 1008 720 180 420 420 Columns 6 through 10 140 0 0 0 0 Columns 11 through 12 0 0 p = Columns 1 through 5 1008 720 180 420 420 Columns 6 through 10 140 0 0 0 0 Columns 11 through 13 0 0 0 p = Columns 1 through 5 1008 720 180 420 420 Columns 6 through 10 140 0 0 0 0 Columns 11 through 14 0 0 0 0 p = 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 p = 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 Column 16 480 p = 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 17 480 3840 p = 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 18 480 3840 4800 p = 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 19 480 3840 4800 5760 p = 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 p = 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 Column 21 12960 p = 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 22 12960 3240 p = 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 23 12960 3240 1944 p = Columns 1 through 5 1008