Cody

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

Solution 716010

Submitted on 17 Aug 2015 by Jonathan
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 = 3.8918 7.8038 11.7357 15.6869 19.6572 19.7166 19.7364 19.7166 19.6572 i = 3

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

s = Columns 1 through 18 3.9703 7.9956 11.9077 15.7789 19.8219 19.8590 19.7849 19.9159 19.9959 19.9041 19.8671 19.9589 19.8279 19.8084 19.7284 19.7654 19.7477 19.7275 Columns 19 through 36 19.7847 19.8647 19.7286 19.6922 19.7124 19.7488 19.7865 19.8274 19.7096 19.8229 19.8406 19.8947 20.0080 20.1258 20.0125 19.9948 19.8229 19.7294 Columns 37 through 49 19.6916 19.8050 19.6916 19.7907 19.7907 19.7907 19.6774 19.6572 19.5787 19.6542 19.5742 19.6512 19.7667 i = 28

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

s = Columns 1 through 18 3.8918 7.8431 11.7349 15.7052 19.7482 19.7684 19.8062 19.8846 19.8462 19.7734 19.8867 19.9408 19.9779 20.0891 20.0506 19.9373 19.8261 19.8441 Columns 19 through 36 19.7523 19.8094 19.8094 19.8666 19.7925 19.7731 19.7159 19.8292 19.7721 19.7329 19.8084 19.9196 19.8645 19.8039 19.8039 19.8219 19.8042 19.7852 Columns 37 through 51 19.8058 19.9368 19.9188 19.7853 19.8230 19.9742 19.8630 19.8987 20.0500 19.9928 19.9928 20.1040 20.1040 20.1040 20.2153 i = 47

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

s = Columns 1 through 18 4.0073 8.0327 11.9645 15.8563 19.8453 19.8083 19.6949 19.7705 19.7705 19.6935 19.5944 19.5742 19.6099 19.5893 19.7203 19.7409 19.8004 19.7276 Columns 19 through 36 19.8454 19.7536 19.8871 19.9062 19.9249 19.9249 20.0167 19.9033 19.8649 19.8271 19.8271 19.6553 19.6751 19.6945 19.7686 19.7686 19.7892 19.7286 Columns 37 through 54 19.7286 19.6735 19.6358 19.6758 19.7166 19.7544 19.7731 19.7731 19.8666 19.8666 19.7694 19.7123 19.6928 19.7105 19.7303 19.8275 19.7669 19.8424 Columns 55 through 58 19.7114 19.7685 19.6507 19.6916 i = 21

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

s = Columns 1 through 18 4.0073 7.8785 11.7497 15.7387 19.7277 19.5916 19.7094 19.7700 19.6728 19.6541 19.7532 19.7896 19.8831 19.8831 19.9201 19.9011 19.9011 19.9011 Columns 19 through 36 19.9011 19.8641 19.8248 19.6707 19.6884 19.7086 19.6095 19.7405 19.8583 19.7273 19.8406 19.8814 19.8814 19.8045 19.8627 19.7886 19.7478 19.7478 Columns 37 through 54 19.7276 19.7646 19.7052 19.8043 19.6931 19.7903 19.7342 19.7742 19.7929 19.8684 19.9047 19.9965 19.9767 19.9581 19.9938 19.8396 19.7284 19.8054 Columns 55 through 68 19.7063 19.5344 19.5550 19.5150 19.4579 19.5185 19.5185 19.5970 19.6370 19.5763 19.6148 19.6949 19.7499 19.8434 i = 44

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

s = 3.8918 7.7836 11.6755 15.5673 19.4591 i = 1