Cody

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

Solution 113582

Submitted on 16 Jul 2012 by Ben
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 = 15 18 19 18 15

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

s = Columns 1 through 10 24 26 22 29 33 28 26 31 24 23 Columns 11 through 20 19 21 20 19 22 26 19 17 18 20 Columns 21 through 30 22 24 18 24 25 28 34 40 34 33 Columns 31 through 40 24 19 17 23 17 22 22 22 16 15 Columns 41 through 45 11 15 11 15 21

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

s = Columns 1 through 10 20 21 23 27 25 21 27 30 32 38 Columns 11 through 20 36 30 24 25 20 23 23 26 22 21 Columns 21 through 30 18 24 21 19 23 29 26 23 23 24 Columns 31 through 40 23 22 23 30 29 22 24 32 26 28 Columns 41 through 47 36 33 33 39 39 39 45

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

s = Columns 1 through 10 25 23 17 21 21 17 12 11 13 12 Columns 11 through 20 19 20 23 19 25 20 27 28 29 29 Columns 21 through 30 34 28 26 24 24 15 16 17 21 21 Columns 31 through 40 22 19 19 16 14 16 18 20 21 21 Columns 41 through 50 26 26 21 18 17 18 19 24 21 25 Columns 51 through 54 18 21 15 17

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

s = Columns 1 through 10 19 12 18 21 16 15 20 22 27 27 Columns 11 through 20 29 28 28 28 28 26 24 16 17 18 Columns 21 through 30 13 20 26 19 25 27 27 23 26 22 Columns 31 through 40 20 20 19 21 18 23 17 22 19 21 Columns 41 through 50 22 26 28 33 32 31 33 25 19 23 Columns 51 through 60 18 9 10 8 5 8 8 12 14 11 Columns 61 through 64 13 17 20 25

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

s = 5