Cody

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

Solution 1984423

Submitted on 21 Oct 2019 by Harsh Patel
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))

mulf = [] mul = 1 mul = 1 2 mul = 1 2 3 mul = 1 2 3 4 mul = 1 2 3 4 5 prod1 = 120 mul = 1 2 3 4 5 2 0 0 0 0 mul = 1 2 3 4 5 2 3 0 0 0 mul = 1 2 3 4 5 2 3 4 0 0 mul = 1 2 3 4 5 2 3 4 5 0 mul = 1 2 3 4 5 2 3 4 5 4 prod1 = 120 480 mul = 1 2 3 4 5 2 3 4 5 4 3 0 0 0 0 mul = 1 2 3 4 5 2 3 4 5 4 3 4 0 0 0 mul = 1 2 3 4 5 2 3 4 5 4 3 4 5 0 0 mul = 1 2 3 4 5 2 3 4 5 4 3 4 5 4 0 mul = 1 2 3 4 5 2 3 4 5 4 3 4 5 4 3 prod1 = 120 480 720 mul = 1 2 3 4 5 2 3 4 5 4 3 4 5 4 3 4 0 0 0 0 mul = 1 2 3 4 5 2 3 4 5 4 3 4 5 4 3 4 5 0 0 0 mul = 1 2 3 4 5 2 3 4 5 4 3 4 5 4 3 4 5 4 0 0 mul = 1 2 3 4 5 2 3 4 5 4 3 4 5 4 3 4 5 4 3 0 mul = 1 2 3 4 5 2 3 4 5 4 3 4 5 4 3 4 5 4 3 2 prod1 = 120 480 720 480 mul = 1 2 3 4 5 2 3 4 5 4 3 4 5 4 3 4 5 4 3 2 5 0 0 0 0 mul = 1 2 3 4 5 2 3 4 5 4 3 4 5 4 3 4 5 4 3 2 5 4 0 0 0 mul = 1 2 3 4 5 2 3 4 5 4 3 4 5 4 3 4 5 4 3 2 5 4 3 0 0 mul = 1 2 3 4 5 2 3 4 5 4 3 4 5 4 3 4 5 4 3 2 5 4 3 2 0 mul = 1 2 3 4 5 2 3 4 5 4 3 4 5 4 3 4 5 4 3 2 5 4 3 2 1 prod1 = 120 480 720 480 120 val = 720 in = 3 i = 3

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

mulf = [] mul = 5 mul = 5 8 mul = 5 8 2 mul = 5 8 2 0 mul = 5 8 2 0 9 prod1 = 0 mul = 5 8 2 0 9 8 0 0 0 0 mul = 5 8 2 0 9 8 2 0 0 0 mul = 5 8 2 0 9 8 2 0 0 0 mul = 5 8 2 0 9 8 2 0 9 0 mul = 5 8 2 0 9 8 2 0 9 7 prod1 = 0 0 mul = 5 8 2 0 9 8 2 0 9 7 2 0 0 0 0 mul = 5 8 2 0 9 8 2 0 9 7 2 0 0 0 0 mul = 5 8 2 0 9 8 2 0 9 7 2 0 9 0 0 mul = 5 8 2 0 9 8 2 0 9 7 2 0 9 7 0 mul = 5 8 2 0 9 8 2 0 9 7 2 0 9 7 4 prod1 = 0 0 0 mul = 5 8 2 0 9 8 2 0 9 7 2 0 9 7 4 0 0 0 0 0 mul = 5 8 2 0 9 8 2 0 9 7 2 0 9 7 4 0 9 0 0 0 mul = 5 8 2 0 9 8 2 0 9 7 2 0 9 7 4 0 9 7 0 0 mul = 5 8 2 0 9 8 2 0 9 7 2 0 9 7 4 0 9 7 4 0 mul = 5 8 2 0 9 8 2 0 9 7 2 0 9 7 4 0 9 7 4 9 prod1 = 0 0 0 0 mul = 5 8 2 0 9 8 2 0 9 7 2 0 9 7 4 0 9 7 4 9 9 0 0 0 0 mul = 5 8 2 0 9 8 2 0 9 7 2 0 9 7 4 0 9 7 4 9 9 7 0 0 0 mul = 5 8 2 0 9 8 2 0 9 7 2 0 9 7 4 0 9 7 4 9 9 7 4 0 0 mul = 5 8 2 0 9 8 2 0 9 7 2 0 9 7 4 0 9 7 4 9 9 7 4 9 0 mul = 5 8 2 0 9 8 2 0 9 7 2 0 9 7 4 0 9 7 4 9 9 7 4 9 4 prod1 = 0 0 0 0 9072 mul = 5 8 2 0 9 8 2 0 9 7 2 0 9 7 4 0 9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 5 9 2 0 mul = 5 8 2 0 9 8 2 0 9 7 2 0 9 7 4 0 9 7 4 9 9 7 4 9 4 7 4 9 4 4 4 9 4 4 5 9 4 4 5 9 4 4 5 9 2 4 5 9 2 3 prod1 = 0 0 0 0 9072 4032 2880 6480 1440 1080 mul = 5 8 2 0 9 8 2 0 9 7 2 0 9 7 4 0 9 7 4 9 9 7 4 9 4 7 4 9 4 4 4 9 4 4 5 9 4 4 5 9 4 4 5 9 2 4 5 9 2 3 5 0 0 0 0...

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

mulf = [] mul = 1 mul = 1 4 mul = 1 4 1 mul = 1 4 1 5 mul = 1 4 1 5 9 prod1 = 180 mul = 1 4 1 5 9 4 0 0 0 0 mul = 1 4 1 5 9 4 1 0 0 0 mul = 1 4 1 5 9 4 1 5 0 0 mul = 1 4 1 5 9 4 1 5 9 0 mul = 1 4 1 5 9 4 1 5 9 2 prod1 = 180 360 mul = 1 4 1 5 9 4 1 5 9 2 1 0 0 0 0 mul = 1 4 1 5 9 4 1 5 9 2 1 5 0 0 0 mul = 1 4 1 5 9 4 1 5 9 2 1 5 9 0 0 mul = 1 4 1 5 9 4 1 5 9 2 1 5 9 2 0 mul = 1 4 1 5 9 4 1 5 9 2 1 5 9 2 6 prod1 = 180 360 540 mul = 1 4 1 5 9 4 1 5 9 2 1 5 9 2 6 5 0 0 0 0 mul = 1 4 1 5 9 4 1 5 9 2 1 5 9 2 6 5 9 0 0 0 mul = 1 4 1 5 9 4 1 5 9 2 1 5 9 2 6 5 9 2 0 0 mul = 1 4 1 5 9 4 1 5 9 2 1 5 9 2 6 5 9 2 6 0 mul = 1 4 1 5 9 4 1 5 9 2 1 5 9 2 6 5 9 2 6 5 prod1 = 180 360 540 2700 mul = 1 4 1 5 9 4 1 5 9 2 1 5 9 2 6 5 9 2 6 5 9 0 0 0 0 mul = 1 4 1 5 9 4 1 5 9 2 1 5 9 2 6 5 9 2 6 5 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3 5 8 9 3 5 8 9 7 5 8 0 0 0 mul = 1 4 1 5 9 4 1 5 9 2 1 5 9 2 6 5 9 2 6 5 9 2 6 5 3 2 6 5 3 5 6 5 3 5 8 5 3 5 8 9 3 5 8 9 7 5 8 9 0 0 mul = 1 4 1 5 9 4 1 5 9 2 1 5 9 2 6 5 9 2 6 5 9 2 6 5 3 2 6 5 3 5 6 5 3 5 8 5 3 5 8 9 3 5 8 9 7 5 8 9 7 0 mul = 1 4 1 5 9 4 1 5 9 2 1 5 9 2 6 5 9 2 6 5 9 2 6 5 3 2 6 5 3 5 6 5 3 5 8 5 3 5 8 9 3 5 8 9 7 5 8 9 7 9 prod1 = 180 360 540 2700 1620 900 3600 5400 7560 22680 mul = 1 4 1 5 9 4 1 5 9 2 1 5 9 2 6 5 9 2 6 5 9 2 6 5 3 2 6 5 3 5 6 5 3 5 8 5 3 5 8 9 3 5 8 9 7 5 8 9 7 9 8...

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

mulf = [] mul = 7 mul = 7 8 mul = 7 8 3 mul = 7 8 3 1 mul = 7 8 3 1 6 prod1 = 1008 mul = 7 8 3 1 6 8 0 0 0 0 mul = 7 8 3 1 6 8 3 0 0 0 mul = 7 8 3 1 6 8 3 1 0 0 mul = 7 8 3 1 6 8 3 1 6 0 mul = 7 8 3 1 6 8 3 1 6 5 prod1 = 1008 720 mul = 7 8 3 1 6 8 3 1 6 5 3 0 0 0 0 mul = 7 8 3 1 6 8 3 1 6 5 3 1 0 0 0 mul = 7 8 3 1 6 8 3 1 6 5 3 1 6 0 0 mul = 7 8 3 1 6 8 3 1 6 5 3 1 6 5 0 mul = 7 8 3 1 6 8 3 1 6 5 3 1 6 5 2 prod1 = 1008 720 180 mul = 7 8 3 1 6 8 3 1 6 5 3 1 6 5 2 1 0 0 0 0 mul = 7 8 3 1 6 8 3 1 6 5 3 1 6 5 2 1 6 0 0 0 mul = 7 8 3 1 6 8 3 1 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 2 0 1 9 prod1 = 1008 720 180 420 420 140 0 0 0 mul = 7 8 3 1 6 8 3 1 6 5 3 1 6 5 2 1 6 5 2 7 6 5 2 7 1 5 2 7 1 2 2 7 1 2 0 7 1 2 0 1 1 2 0 1 9 2 0 0 0 0 mul = 7 8 3 1 6 8 3 1 6 5 3 1 6 5 2 1 6 5 2 7 6 5 2 7 1 5 2 7 1 2 2 7 1 2 0 7 1 2 0 1 1 2 0 1 9 2 0 0 0 0 mul = 7 8 3 1 6 8 3 1 6 5 3 1 6 5 2 1 6 5 2 7 6 5 2 7 1 5 2 7 1 2 2 7 1 2 0 7 1 2 0 1 1 2 0 1 9 2 0 1 0 0 mul = 7 8 3 1 6 8 3 1 6 5 3 1 6 5 2 1 6 5 2 7 6 5 2 7 1 5 2 7 1 2 2 7 1 2 0 7 1 2 0 1 1 2 0 1 9 2 0 1 9 0 mul = 7 8 3 1 6 8 3 1 6 5 3 1 6 5 2 1 6 5 2 7 6 5 2 7 1 5 2 7 1 2 2 7 1 2 0 7 1 2 0 1 1 2 0 1 9 2 0 1 9 0 prod1 = 1008 720 180 420 420 140 0 0 0 0 mul = 7 8 3 1 6 8 3 1 6 5 3 1 6 5 2 1 6 5 2 7 6 5 2 7 1 5 2 7 1 2 2 7 1 2 0 7 1 2 0 1 1 2 0 1 9 ...

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

mulf = [] mul = 7 mul = 7 0 mul = 7 0 0 mul = 7 0 0 6 mul = 7 0 0 6 6 prod1 = 0 mul = 7 0 0 6 6 0 0 0 0 0 mul = 7 0 0 6 6 0 0 0 0 0 mul = 7 0 0 6 6 0 0 6 0 0 mul = 7 0 0 6 6 0 0 6 6 0 mul = 7 0 0 6 6 0 0 6 6 0 prod1 = 0 0 mul = 7 0 0 6 6 0 0 6 6 0 0 0 0 0 0 mul = 7 0 0 6 6 0 0 6 6 0 0 6 0 0 0 mul = 7 0 0 6 6 0 0 6 6 0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