Cody

Problem 54. Maximum running product for a string of numbers

Solution 2637880

Submitted on 1 Jul 2020 by 春樹 内糸
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))

idx = 1 d = 120 idx = 1 d = 480 idx = 2 d = 720 idx = 3

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

idx = 1 d = 9072 idx = 5 d = 31104 idx = 28

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

idx = 1 d = 180 idx = 1 d = 360 idx = 2 d = 540 idx = 3 d = 2700 idx = 4 d = 3600 idx = 7 d = 5400 idx = 8 d = 7560 idx = 9 d = 22680 idx = 10 d = 59049 idx = 47

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

idx = 1 d = 1008 idx = 1 d = 1080 idx = 15 d = 3840 idx = 17 d = 4800 idx = 18 d = 5760 idx = 19 d = 12960 idx = 21

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

idx = 1 d = 450 idx = 7 d = 600 idx = 8 d = 1600 idx = 9 d = 2240 idx = 11 d = 3024 idx = 42 d = 4032 idx = 43 d = 9072 idx = 44

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

idx = 1 d = 1 idx = 1

Suggested Problems

More from this Author95

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!