Cody

Solution 662590

Submitted on 29 Apr 2015 by Li Yjie
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 = 1 2 3 4 5 4 3 2 1 n = 5 a = 15 a = 15 18 a = 15 18 19 a = 15 18 19 18 a = 15 18 19 18 15 ind = 3

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

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

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

s = Columns 1 through 16 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 Columns 17 through 32 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5 0 Columns 33 through 48 2 8 8 4 1 9 7 1 6 9 3 9 9 3 9 9 Columns 49 through 51 9 9 9 n = 47 a = 20 a = 20 21 a = 20 21 23 a = 20 21 23 27 a = 20 21 23 27 25 a = 20 21 23 27 25 21 a = 20 21 23 27 25 21 27 a = 20 21 23 27 25 21 27 30 a = 20 21 23 27 25 21 27 30 32 a = 20 21 23 27 25 21 27 30 32 38 a = 20 21 23 27 25 21 27 30 32 38 36 a = 20 21 23 27 25 21 27 30 32 38 36 30 a = 20 21 23 27 25 21 27 30 32 38 36 30 24 a = 20 21 23 27 25 21 27 30 32 38 36 30 24 25 a = 20 21 23 27 25 21 27 30 32 38 36 30 24 25 20 a = 20 21 23 27 25 21 27 30 32 38 36 30 24 25 20 23 a = Columns 1 through 16 20 21 23 27 25 21 27 30 32 38 36 30 24 25 20 23 Column 17 23 a = Columns 1 through 16 20 21 23 27 25 21 27 30 32 38 36 30 24 25 20 23 Columns 17 through 18 23 26 a = Columns 1 through 16 20 21 23 27 25 21 27 30 32 38 36 30 24 25 20 23 Columns 17 through 19 23 26 22 a = Columns 1 through 16 20 21 23 27 25 21 27 30 32 38 36 30 24 25 20 23 Columns 17 through 20 23 26 22 21 a = Columns 1 through 16 20 21 23 27 25 21 27 30 32 38 36 30 24 25 20 23 Columns 17 through 21 23 26 22 21 18 a = Columns 1 through 16 20 21 23 27 25 21 27 30 32 38 36 30 24 25 20 23 Columns 17 through 22 23 26 22 21 18 24 a = Columns 1 through 16 20 21 23 27 25 21 27 30 32 38 36 30 24 25 20 23 Columns 17 through 23 23 26 22 21 18 24 21 a = Columns 1 through 16 20 21 23 27 25 21 27 30 32 38 36 30 24 25 20 23 Columns 17 through 24 23 26 22 21 18 24 21 19 a = Columns 1 through 16 20 21 23 27 25 21 27 30 32 38 36 30 24 25 20 23 Columns 17 through 25 23 26 22 21 18 24 21 19 23 a = Columns 1 through 16 20 21 23 27 25 21 27 30 32 38 36 30 24 25 20 23 Columns 17 through 26 23 26 22 21 18 24 21 19 23 29 a = Columns 1 through 16 20 21 23 27 25 21 27 30 32 38 36 30 24 25 20 23 Columns 17 through 27 23 26 22 21 18 24 21 19 23 29 26 a = Columns 1 through 16 20 21 23 27 25 21 27 30 32 38 36 30 24 25 20 23 Columns 17 through 28 23 26 22 21 18 24 21 19 23 29 26 23 a = Columns 1 through 16 20 21 23 27 25 21 27 30 32 38 36 30 24 25 20 23 Columns 17 through 29 23 26 22 21 18 24 21 19 23 29 26 23 23 a = Columns 1 through 16 20 21 23 27 25 21 27 30 32 38 36 30 24 25 20 23 Columns 17 through 30 23 26 22 21 18 24 21 19 23 29 26 23 23 24 a = Columns 1 through 16 20 21 23 27 25 21 27 30 32 38 36 30 24 25 20 23 Columns 17 through 31 23 26 22 21 18 24 21 19 23 29 26 23 23 24 23 a = Columns 1 through 16 20 21 23 27 25 21 27 30 32 38 36 30 24 25 20 23 Columns 17 through 32 23 26 22 21 18 24 21 19 23 29 26 23 23 24 23 22 a = Columns 1 through 16 20 21 23 27 25 21 27 30 32 38 36 30 24 25 20 23 Columns 17 through 32 23 26 22 21 18 24 21 19 23 29 26 23 23 24 23 22 Column 33 23 a = Columns 1 through 16 20 21 23 27 25 21 27 30 32 38 36 30 24 25 20 23 Columns 17 through 32 23 26 22 21 18 24 21 19 23 29 26 23 23 24 23 22 Columns 33 through 34 23 30 a = Columns 1 through 16 20 21 23 27 25 21 27 30 32 38 36 30 24 25 20 23 Columns 17 through 32 23 26 22 21 18 24 21 19 23 29 26 23 23 24 23 22 Columns 33 through 35 23 30 29 a = Columns 1 through 16 20 21 23 27 25 21 27 30 32 38 36 30 24 25 20 23 Columns 17 through 32 23 26 22 21 18 24 21 19 23 29 26 23 23 24 23 22 Columns 33 through 36 23 30 29 22 a = Columns 1 through 16 20 21 23 27 25 21 27 30 32 38 36 30 24 25 20 23 Columns 17 through 32 23 26 22 21 18 24 21 19 23 29 26 23 23 24 23 22 Columns 33 through 37 23 30 29 22 24 a = Columns 1 through 16 20 21 23 27 25 21 27 30 32 38 36 30 24 25 20 23 Columns 17 through 32 23 26 22 21 18 24 21 19 23 29 26 23 23 24 23 22 Columns 33 through 38 23 30 29 22 24 32 a = Columns 1 through 16 20 21 23 27 25 21 27 30 32 38 36 30 24 25 20 23 Columns 17 through 32 23 26 22 21 18 24 21 19 23 29 26 23 23 24 23 22 Columns 33 through 39 23 30 29 22 24 32 26 a = Columns 1 through 16 20 21 23 27 25 21 27 30 32 38 36 30 24 25 20 23 Columns 17 through 32 23 26 22 21 18 24 21 19 23 29 26 23 23 24 23 22 Columns 33 through 40 23 30 29 22 24 32 26 28 a = Columns 1 through 16 20 21 23 27 25 21 27 30 32 38 36 30 24 25 20 23 Columns 17 through 32 23 26 22 21 18 24 21 19 23 29 26 23 23 24 23 22 Columns 33 through 41 23 30 29 22 24 32 26 28 36 a = Columns 1 through 16 20 21 23 27 25 21 27 30 32 38 36 30 24 25 20 23 Columns 17 through 32 23 26 22 21 18 24 21 19 23 29 26 23 23 24 23 22 Columns 33 through 42 23 30 29 22 24 32 26 28 36 33 a = Columns 1 through 16 20 21 23 27 25 21 27 30 32 38 36 30 24 25 20 23 Columns 17 through 32 23 26 22 21 18 24 21 19 23 29 26 23 23 24 23 22 Columns 33 through 43 23 30 29 22 24 32 26 28 36 33 33 a = Columns 1 through 16 20 21 23 27 25 21 27 30 32 38 36 30 24 25 20 23 Columns 17 through 32 23 26 22 21 18 24 21 19 23 29 26 23 23 24 23 22 Columns 33 through 44 23 30 29 22 24 32 26 28 36 33 33 39 a = Columns 1 through 16 20 21 23 27 25 21 27 30 32 38 36 30 24 25 20 23 Columns 17 through 32 23 26 22 21 18 24 21 19 23 29 26 23 23 24 23 22 Columns 33 through 45 23 30 29 22 24 32 26 28 36 33 33 39 39 a = Columns 1 through 16 20 21 23 27 25 21 27 30 32 38 36 30 24 25 20 23 Columns 17 through 32 23 26 22 21 18 24 21 19 23 29 26 23 23 24 23 22 Columns 33 through 46 23 30 29 22 24 32 26 28 36 33 33 39 39 39 a = Columns 1 through 16 20 21 23 27 25 21 27 30 32 38 36 30 24 25 20 23 Columns 17 through 32 23 26 22 21 18 24 21 19 23 29 26 23 23 24 23 22 Columns 33 through 47 23 30 29 22 24 32 26 28 36 33 33 39 39 39 45 ind = 47

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

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

5   Fail

Suggested Problems

More from this Author95