Cody

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

Solution 428380

Submitted on 8 Apr 2014 by Mick Warehime
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))

n = 1 2 3 4 5 4 3 2 1 in = 1 2 3 4 5 2 3 4 5 6 3 4 5 6 7 4 5 6 7 8 5 6 7 8 9 i = 3

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

n = 5 8 2 0 9 7 4 9 4 4 5 9 2 3 0 7 8 1 6 4 0 6 2 8 6 2 0 8 9 9 8 6 2 8 0 3 4 8 2 5 3 4 2 1 1 7 0 6 7 in = Columns 1 through 16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Columns 17 through 32 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 Columns 33 through 45 33 34 35 36 37 38 39 40 41 42 43 44 45 34 35 36 37 38 39 40 41 42 43 44 45 46 35 36 37 38 39 40 41 42 43 44 45 46 47 36 37 38 39 40 41 42 43 44 45 46 47 48 37 38 39 40 41 42 43 44 45 46 47 48 49 i = 28

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

n = 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5 0 2 8 8 4 1 9 7 1 6 9 3 9 9 3 9 9 9 9 9 in = Columns 1 through 16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Columns 17 through 32 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 Columns 33 through 47 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 i = 47

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

n = 7 8 3 1 6 5 2 7 1 2 0 1 9 0 9 1 4 5 6 4 8 5 6 6 9 2 3 4 6 0 3 4 8 6 1 0 4 5 4 3 2 6 6 4 8 2 1 3 3 9 3 6 0 7 2 6 0 2 in = Columns 1 through 16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Columns 17 through 32 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 Columns 33 through 48 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 Columns 49 through 54 49 50 51 52 53 54 50 51 52 53 54 55 51 52 53 54 55 56 52 53 54 55 56 57 53 54 55 56 57 58 i = 21

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

n = 7 0 0 6 6 0 6 3 1 5 5 8 8 1 7 4 8 8 1 5 2 0 9 2 0 9 6 2 8 2 9 2 5 4 0 9 1 7 1 5 3 6 4 3 6 7 8 9 2 5 9 0 3 6 0 0 1 1 3 3 0 5 3 0 5 4 8 8 in = Columns 1 through 16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Columns 17 through 32 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 Columns 33 through 48 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 Columns 49 through 64 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 i = 44

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

n = 1 1 1 1 1 in = 1 2 3 4 5 i = 1