Cody

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

Solution 1793785

Submitted on 20 Apr 2019 by Jarrod Dowdall
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))

Q = 120 Q = 120 480 Q = 120 480 720 Q = 120 480 720 480 Q = 120 480 720 480 120

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

Q = 0 Q = 0 0 Q = 0 0 0 Q = 0 0 0 0 Q = 0 0 0 0 9072 Q = 0 0 0 0 9072 4032 Q = 0 0 0 0 9072 4032 2880 Q = 0 0 0 0 9072 4032 2880 6480 Q = 0 0 0 0 9072 4032 2880 6480 1440 Q = 0 0 0 0 9072 4032 2880 6480 1440 1080 Q = 0 0 0 0 9072 4032 2880 6480 1440 1080 0 Q = 0 0 0 0 9072 4032 2880 6480 1440 1080 0 0 Q = 0 0 0 0 9072 4032 2880 6480 1440 1080 0 0 0 Q = 0 0 0 0 9072 4032 2880 6480 1440 1080 0 0 0 0 Q = 0 0 0 0 9072 4032 2880 6480 1440 1080 0 0 0 0 0 Q = Columns 1 through 15 0 0 0 0 9072 4032 2880 6480 1440 1080 0 0 0 0 0 Column 16 1344 Q = Columns 1 through 15 0 0 0 0 9072 4032 2880 6480 1440 1080 0 0 0 0 0 Columns 16 through 17 1344 0 Q = Columns 1 through 15 0 0 0 0 9072 4032 2880 6480 1440 1080 0 0 0 0 0 Columns 16 through 18 1344 0 0 Q = Columns 1 through 15 0 0 0 0 9072 4032 2880 6480 1440 1080 0 0 0 0 0 Columns 16 through 19 1344 0 0 0 Q = Columns 1 through 15 0 0 0 0 9072 4032 2880 6480 1440 1080 0 0 0 0 0 Columns 16 through 20 1344 0 0 0 0 Q = Columns 1 through 15 0 0 0 0 9072 4032 2880 6480 1440 1080 0 0 0 0 0 Columns 16 through 21 1344 0 0 0 0 0 Q = Columns 1 through 15 0 0 0 0 9072 4032 2880 6480 1440 1080 0 0 0 0 0 Columns 16 through 22 1344 0 0 0 0 0 1152 Q = Columns 1 through 15 0 0 0 0 9072 4032 2880 6480 1440 1080 0 0 0 0 0 Columns 16 through 23 1344 0 0 0 0 0 1152 0 Q = Columns 1 through 15 0 0 0 0 9072 4032 2880 6480 1440 1080 0 0 0 0 0 Columns 16 through 24 1344 0 0 0 0 0 1152 0 0 Q = Columns 1 through 15 0 0 0 0 9072 4032 2880 6480 1440 1080 0 0 0 0 0 Columns 16 through 25 1344 0 0 0 0 0 1152 0 0 0 Q = Columns 1 through 15 0 0 0 0 9072 4032 2880 6480 1440 1080 0 0 0 0 0 Columns 16 through 26 1344 0 0 0 0 0 1152 0 0 0 0 Q = Columns 1 through 15 0 0 0 0 9072 4032 2880 6480 1440 1080 0 0 0 0 0 Columns 16 through 27 1344 0 0 0 0 0 1152 0 0 0 0 0 Q = Columns 1 through 15 0 0 0 0 9072 4032 2880 6480 1440 1080 0 0 0 0 0 Columns 16 through 28 1344 0 0 0 0 0 1152 0 0 0 0 0 31104 Q = Columns 1 through 15 0 0 0 0 9072 4032 2880 6480 1440 1080 0 0 0 0 0 Columns 16 through 29 1344 0 0 0 0 0 1152 0 0 0 0 0 31104 7776 Q = Columns 1 through 15 0 0 0 0 9072 4032 2880 6480 1440 1080 0 0 0 0 0 Columns 16 through 30 1344 0 0 0 0 0 1152 0 0 0 0 0 31104 7776 6912 Q = Columns 1 through 15 0 0 0 0 9072 4032 2880 6480 1440 1080 0 0 0 0 0 Columns 16 through 30 1344 0 0 0 0 0 1152 0 0 0 0 0 31104 7776 6912 Column 31 0 Q = Columns 1 through 15 0 0 0 0 9072 4032 2880 6480 1440 1080 0 0 0 0 0 Columns 16 through 30 1344 0 0 0 0 0 1152 0 0 0 0 0 31104 7776 6912 Columns 31 through 32 0 0 Q = Columns 1 through 15 0 0 0 0 9072 4032 2880 6480 1440 1080 0 0 0 0 0 Columns 16 through 30 1344 0 0 0 0 0 1152 0 0 0 0 0 31104 7776 6912 Columns 31 through 33 0 0 0 Q = Columns 1 through 15 0 0 0 0 9072 4032 2880 6480 1440 1080 0 0 0 0 0 Columns 16 through 30 1344 0 0 0 0 0 1152 0 0 0 0 0 31104 7776 6912 Columns 31 through 34 0 0 0 0 Q = Columns 1 through 15 0 0 0 0 9072 4032 2880 6480 1440 1080 0 0 0 0 0 Columns 16 through 30 1344 0 0 0 0 0 1152 0 0 0 0 0 31104 7776 6912 Columns 31 through 35 0 0 0 0 0 Q = Columns 1 through 15 0 0 0 0 9072 4032 2880 6480 1440 1080 0 0 0 0 0 Columns 16 through 30 1344 0 0 0 0 0 1152 0 0 0 0 0 31104 7776 6912 Columns 31 through 36 0 0 0 0 0 960 Q = Columns 1 through 15 0 0 0 0 9072 4032 2880 6480 1440 1080 0 0 0 0 0 Columns 16 through 30 1344 0 0 0 0 0 1152 0 0 0 0 0 31104 7776 6912 Columns 31 through 37 0 0 0 0 0 960 960 Q = Columns 1 through 15 0...

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

Q = 180 Q = 180 360 Q = 180 360 540 Q = 180 360 540 2700 Q = 180 360 540 2700 1620 Q = 180 360 540 2700 1620 900 Q = 180 360 540 2700 1620 900 3600 Q = 180 360 540 2700 1620 900 3600 5400 Q = 180 360 540 2700 1620 900 3600 5400 7560 Q = 180 360 540 2700 1620 900 3600 5400 7560 22680 Q = 180 360 540 2700 1620 900 3600 5400 7560 22680 13608 Q = 180 360 540 2700 1620 900 3600 5400 7560 22680 13608 3402 Q = 180 360 540 2700 1620 900 3600 5400 7560 22680 13608 3402 1134 Q = 180 360 540 2700 1620 900 3600 5400 7560 22680 13608 3402 1134 1296 Q = 180 360 540 2700 1620 900 3600 5400 7560 22680 13608 3402 1134 1296 576 Q = Columns 1 through 15 180 360 540 2700 1620 900 3600 5400 7560 22680 13608 3402 1134 1296 576 Column 16 1152 Q = Columns 1 through 15 180 360 540 2700 1620 900 3600 5400 7560 22680 13608 3402 1134 1296 576 Columns 16 through 17 1152 1152 Q = Columns 1 through 15 180 360 540 2700 1620 900 3600 5400 7560 22680 13608 3402 1134 1296 576 Columns 16 through 18 1152 1152 2304 Q = Columns 1 through 15 180 360 540 2700 1620 900 3600 5400 7560 22680 13608 3402 1134 1296 576 Columns 16 through 19 1152 1152 2304 1152 Q = Columns 1 through 15 180 360 540 2700 1620 900 3600 5400 7560 22680 13608 3402 1134 1296 576 Columns 16 through 20 1152 1152 2304 1152 864 Q = Columns 1 through 15 180 360 540 2700 1620 900 3600 5400 7560 22680 13608 3402 1134 1296 576 Columns 16 through 21 1152 1152 2304 1152 864 432 Q = Columns 1 through 15 180 360 540 2700 1620 900 3600 5400 7560 22680 13608 3402 1134 1296 576 Columns 16 through 22 1152 1152 2304 1152 864 432 1728 Q = Columns 1 through 15 180 360 540 2700 1620 900 3600 5400 7560 22680 13608 3402 1134 1296 576 Columns 16 through 23 1152 1152 2304 1152 864 432 1728 864 Q = Columns 1 through 15 180 360 540 2700 1620 900 3600 5400 7560 22680 13608 3402 1134 1296 576 Columns 16 through 24 1152 1152 2304 1152 864 432 1728 864 432 Q = Columns 1 through 15 180 360 540 2700 1620 900 3600 5400 7560 22680 13608 3402 1134 1296 576 Columns 16 through 25 1152 1152 2304 1152 864 432 1728 864 432 1008 Q = Columns 1 through 15 180 360 540 2700 1620 900 3600 5400 7560 22680 13608 3402 1134 1296 576 Columns 16 through 26 1152 1152 2304 1152 864 432 1728 864 432 1008 3024 Q = Columns 1 through 15 180 360 540 2700 1620 900 3600 5400 7560 22680 13608 3402 1134 1296 576 Columns 16 through 27 1152 1152 2304 1152 864 432 1728 864 432 1008 3024 1890 Q = Columns 1 through 15 180 360 540 2700 1620 900 3600 5400 7560 22680 13608 3402 1134 1296 576 Columns 16 through 28 1152 1152 2304 1152 864 432 1728 864 432 1008 3024 1890 0 Q = Columns 1 through 15 180 360 540 2700 1620 900 3600 5400 7560 22680 13608 3402 1134 1296 576 Columns 16 through 29 1152 1152 2304 1152 864 432 1728 864 432 1008 3024 1890 0 0 Q = Columns 1 through 15 180 360 540 2700 1620 900 3600 5400 7560 22680 13608 3402 1134 1296 576 Columns 16 through 30 1152 1152 2304 1152 864 432 1728 864 432 1008 3024 1890 0 0 0 Q = Columns 1 through 15 180 360 540 2700 1620 900 3600 5400 7560 22680 13608 3402 1134 1296 576 Columns 16 through 30 1152 1152 2304 1152 864 432 1728 864 432 1008 3024 1890 0 0 0 Column 31 0 Q = Columns 1 through 15 180 360 540 2700 1620 900 3600 5400 7560 22680 13608 3402 1134 1296 576 Columns 16 through 30 1152 1152 2304 1152 864 432 1728 864 432 1008 3024 1890 0 0 0 Columns 31 through 32 0 0 Q = Columns 1 through 15 180 360 540 2700 1620 900 3600 5400 7560 22680 13608 3402 1134 1296 576 Columns 16 through 30 1152 1152 2304 1152 864 432 1728 864 432 1008 3024 1890 0 0 0 Columns 31 through 33 0 0 512 Q = Columns 1 through 15 180 360 540 2700 1620 900 3600 5400 7560 22680 13608 3402 1134 1296 576 Columns 16 through 30 1152 1152 2304 1152 864 432 1728 864 432 1008 3024 1890 0 0 0 Columns 31 through 34 0 0 512 2304 Q = Columns 1 through 15 180 360 540 2700 1620 900 3600 5400 7560 22680 13608 3402 1134 1296 576 Columns 16 through 30 1152 1152 2304 1152 864 432 1728 864 432 1008 3024 1890 0 0 0 Columns 31 through 35 0 0 512 2304 2016 Q = Columns 1 through 15 180 360 540 2700 1620 900 3600 5400 7560 22680 13608 3402 1134 1296 576 Columns 16 through 30 1152 1152 2304 1152 864 432 1728 864 432 1008 3024 1890 0 0 0 Columns 31 through 36 0 0 512 2304 2016 252 Q = Columns 1 through 15 180 360 540 2700 1620 900 3600 5400 7560 22680 13608 3402 1134 1296 576 Columns 16 through 30 1152 1152 2304 1152 864 432 1728 864 432 1008 3024 1890 0 0 0 Columns 31 through 37 0 0 512 2304 2016 252 378 Q = Columns 1 ...

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

Q = 1008 Q = 1008 720 Q = 1008 720 180 Q = 1008 720 180 420 Q = 1008 720 180 420 420 Q = 1008 720 180 420 420 140 Q = 1008 720 180 420 420 140 0 Q = 1008 720 180 420 420 140 0 0 Q = 1008 720 180 420 420 140 0 0 0 Q = 1008 720 180 420 420 140 0 0 0 0 Q = 1008 720 180 420 420 140 0 0 0 0 0 Q = 1008 720 180 420 420 140 0 0 0 0 0 0 Q = 1008 720 180 420 420 140 0 0 0 0 0 0 0 Q = 1008 720 180 420 420 140 0 0 0 0 0 0 0 0 Q = 1008 720 180 420 420 140 0 0 0 0 0 0 0 0 1080 Q = Columns 1 through 15 1008 720 180 420 420 140 0 0 0 0 0 0 0 0 1080 Column 16 480 Q = Columns 1 through 15 1008 720 180 420 420 140 0 0 0 0 0 0 0 0 1080 Columns 16 through 17 480 3840 Q = Columns 1 through 15 1008 720 180 420 420 140 0 0 0 0 0 0 0 0 1080 Columns 16 through 18 480 3840 4800 Q = Columns 1 through 15 1008 720 180 420 420 140 0 0 0 0 0 0 0 0 1080 Columns 16 through 19 480 3840 4800 5760 Q = Columns 1 through 15 1008 720 180 420 420 140 0 0 0 0 0 0 0 0 1080 Columns 16 through 20 480 3840 4800 5760 5760 Q = Columns 1 through 15 1008 720 180 420 420 140 0 0 0 0 0 0 0 0 1080 Columns 16 through 21 480 3840 4800 5760 5760 12960 Q = Columns 1 through 15 1008 720 180 420 420 140 0 0 0 0 0 0 0 0 1080 Columns 16 through 22 480 3840 4800 5760 5760 12960 3240 Q = Columns 1 through 15 1008 720 180 420 420 140 0 0 0 0 0 0 0 0 1080 Columns 16 through 23 480 3840 4800 5760 5760 12960 3240 1944 Q = Columns 1 through 15 1008 720 180 420 420 140 0 0 0 0 0 0 0 0 1080 Columns 16 through 24 480 3840 4800 5760 5760 12960 3240 1944 1296 Q = Columns 1 through 15 1008 720 180 420 420 140 0 0 0 0 0 0 0 0 1080 Columns 16 through 25 480 3840 4800 5760 5760 12960 3240 1944 1296 1296 Q = Columns 1 through 15 1008 720 180 420 420 140 0 0 0 0 0 0 0 0 1080 Columns 16 through 26 480 3840 4800 5760 5760 12960 3240 1944 1296 1296 0 Q = Columns 1 through 15 1008 720 180 420 420 140 0 0 0 0 0 0 0 0 1080 Columns 16 through 27 480 3840 4800 5760 5760 12960 3240 1944 1296 1296 0 0 Q = Columns 1 through 15 1008 720 180 420 420 140 0 0 0 0 0 0 0 0 1080 Columns 16 through 28 480 3840 4800 5760 5760 12960 3240 1944 1296 1296 0 0 0 Q = Columns 1 through 15 1008 720 180 420 420 140 0 0 0 0 0 0 0 0 1080 Columns 16 through 29 480 3840 4800 5760 5760 12960 3240 1944 1296 1296 0 0 0 0 Q = Columns 1 through 15 1008 720 180 420 420 140 0 0 0 0 0 0 0 0 1080 Columns 16 through 30 480 3840 4800 5760 5760 12960 3240 1944 1296 1296 0 0 0 0 0 Q = Columns 1 through 15 1008 720 180 420 420 140 0 0 0 0 0 0 0 0 1080 Columns 16 through 30 480 3840 4800 5760 5760 12960 3240 1944 1296 1296 0 0 0 0 0 Column 31 576 Q = Columns 1 through 15 1008 720 180 420 420 140 0 0 0 0 0 0 0 0 1080 Columns 16 through 30 480 3840 4800 5760 5760 12960 3240 1944 1296 1296 0 0 0 0 0 Columns 31 through 32 576 0 Q = Columns 1 through 15 1008 720 180 420 420 140 0 0 0 0 0 0 0 0 1080 Columns 16 through 30 480 3840 4800 5760 5760 12960 3240 1944 1296 1296 0 0 0 0 0 Columns 31 through 33 576 0 0 Q = Columns 1 through 15 1008 720 180 420 420 140 0 0 0 0 0 0 0 0 1080 Columns 16 through 30 480 3840 4800 5760 5760 12960 3240 1944 1296 1296 0 0 0 0 0 Columns 31 through 34 576 0 0 0 Q = Columns 1 through 15 1008 720 180 420 420 140 0 0 0 0 0 0 0 0 1080 Columns 16 through 30 480 3840 4800 5760 5760 12960 3240 1944 1296 1296 0 0 0 0 0 Columns 31 through 35 576 0 0 0 0 Q = Columns 1 through 15 1008 720 180 420 420 140 0 0 0 0 0 0 0 0 1080 Columns 16 through 30 480 3840 4800 5760 5760 12960 3240 1944 1296 1296 0 0 0 0 0 Columns 31 through 36 576 0 0 0 0 0 Q = Columns 1 through 15 1008 720 180 420 420 140 0 0 0 0 0 0 0 0 1080 Columns 16 through 30 480 3840 4800 5760 5760 12960 3240 1944 1296 1296 0 0 0 0 0 Columns 31 through 37 576 0 0 0 0 ...

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

Q = 0 Q = 0 0 Q = 0 0 0 Q = 0 0 0 0 Q = 0 0 0 0 0 Q = 0 0 0 0 0 0 Q = 0 0 0 0 0 0 450 Q = 0 0 0 0 0 0 450 600 Q = 0 0 0 0 0 0 450 600 1600 Q = 0 0 0 0 0 0 450 600 1600 1600 Q = 0 0 0 0 0 0 450 600 1600 1600 2240 Q = 0 0 0 0 0 0 450 600 1600 1600 2240 1792 Q = 0 0 0 0 0 0 450 600 1600 1600 2240 1792 1792 Q = 0 0 0 0 0 0 450 600 1600 1600 2240 1792 1792 1792 Q = 0 0 0 0 0 0 450 600 1600 1600 2240 1792 1792 1792 1792 Q = Columns 1 through 15 0 0 0 0 0 0 450 600 1600 1600 2240 1792 1792 1792 1792 Column 16 1280 Q = Columns 1 through 15 0 0 0 0 0 0 450 600 1600 1600 2240 1792 1792 1792 1792 Columns 16 through 17 1280 640 Q = Columns 1 through 15 0 0 0 0 0 0 450 600 1600 1600 2240 1792 1792 1792 1792 Columns 16 through 18 1280 640 0 Q = Columns 1 through 15 0 0 0 0 0 0 450 600 1600 1600 2240 1792 1792 1792 1792 Columns 16 through 19 1280 640 0 0 Q = Columns 1 through 15 0 0 0 0 0 0 450 600 1600 1600 2240 1792 1792 1792 1792 Columns 16 through 20 1280 640 0 0 0 Q = Columns 1 through 15 0 0 0 0 0 0 450 600 1600 1600 2240 1792 1792 1792 1792 Columns 16 through 21 1280 640 0 0 0 0 Q = Columns 1 through 15 0 0 0 0 0 0 450 600 1600 1600 2240 1792 1792 1792 1792 Columns 16 through 22 1280 640 0 0 0 0 0 Q = Columns 1 through 15 0 0 0 0 0 0 450 600 1600 1600 2240 1792 1792 1792 1792 Columns 16 through 23 1280 640 0 0 0 0 0 0 Q = Columns 1 through 15 0 0 0 0 0 0 450 600 1600 1600 2240 1792 1792 1792 1792 Columns 16 through 24 1280 640 0 0 0 0 0 0 0 Q = Columns 1 through 15 0 0 0 0 0 0 450 600 1600 1600 2240 1792 1792 1792 1792 Columns 16 through 25 1280 640 0 0 0 0 0 0 0 0 Q = Columns 1 through 15 0 0 0 0 0 0 450 600 1600 1600 2240 1792 1792 1792 1792 Columns 16 through 26 1280 640 0 0 0 0 0 0 0 0 1728 Q = Columns 1 through 15 0 0 0 0 0 0 450 600 1600 1600 2240 1792 1792 1792 1792 Columns 16 through 27 1280 640 0 0 0 0 0 0 0 0 1728 1728 Q = Columns 1 through 15 0 0 0 0 0 0 450 600 1600 1600 2240 1792 1792 1792 1792 Columns 16 through 28 1280 640 0 0 0 0 0 0 0 0 1728 1728 576 Q = Columns 1 through 15 0 0 0 0 0 0 450 600 1600 1600 2240 1792 1792 1792 1792 Columns 16 through 29 1280 640 0 0 0 0 0 0 0 0 1728 1728 576 1440 Q = Columns 1 through 15 0 0 0 0 0 0 450 600 1600 1600 2240 1792 1792 1792 1792 Columns 16 through 30 1280 640 0 0 0 0 0 0 0 0 1728 1728 576 1440 720 Q = Columns 1 through 15 0 0 0 0 0 0 450 600 1600 1600 2240 1792 1792 1792 1792 Columns 16 through 30 1280 640 0 0 0 0 0 0 0 0 1728 1728 576 1440 720 Column 31 0 Q = Columns 1 through 15 0 0 0 0 0 0 450 600 1600 1600 2240 1792 1792 1792 1792 Columns 16 through 30 1280 640 0 0 0 0 0 0 0 0 1728 1728 576 1440 720 Columns 31 through 32 0 0 Q = Columns 1 through 15 0 0 0 0 0 0 450 600 1600 1600 2240 1792 1792 1792 1792 Columns 16 through 30 1280 640 0 0 0 0 0 0 0 0 1728 1728 576 1440 720 Columns 31 through 33 0 0 0 Q = Columns 1 through 15 0 0 0 0 0 0 450 600 1600 1600 2240 1792 1792 1792 1792 Columns 16 through 30 1280 640 0 0 0 0 0 0 0 0 1728 1728 576 1440 720 Columns 31 through 34 0 0 0 0 Q = Columns 1 through 15 0 0 0 0 0 0 450 600 1600 1600 2240 1792 1792 1792 1792 Columns 16 through 30 1280 640 0 0 0 0 0 0 0 0 1728 1728 576 1440 720 Columns 31 through 35 0 0 0 0 0 Q = Columns 1 through 15 0 0 0 0 0 0 450 600 1600 1600 2240 1792 1792 1792 1792 Columns 16 through 30 1280 640 0 0 0 0 0 0 0 0 1728 1728 576 1440 720 Columns 31 through 36 0 0 0 0 0 315 Q = Columns 1 through 15 0 0 0 0 0 0 450 600 1600 1600 2240 1792 1792 1792 1792 Columns 16 through 30 1280 640 0 0 0 0 0 0 0 0 1728 1728 576 1440 720 Columns 31 through 37 0 0 0 0 0 315 105 Q = Columns 1 through 15 0 0 0 0 0 0 450 600 1600 1600 2240 1792 1792 1792...

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

Q = 1