Cody

Solution 1236053

Submitted on 21 Jul 2017 by Salvatore Lacava
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))

bla = 1×9 cell array '1' '2' '3' '4' '5' '4' '3' '2' '1' p = 0 s = '23454321' s = '3454321' s = '454321' s = '54321' s = '4321' s = '321' s = '21' s = '1' s = '' p = 120 p = 120 480 p = 120 480 720 p = 120 480 720 480 p = 120 480 720 480 120 m = 720 idx = 3

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

bla = 1×49 cell array Columns 1 through 25 '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' Columns 26 through 49 '2' '0' '8' '9' '9' '8' '6' '2' '8' '0' '3' '4' '8' '2' '5' '3' '4' '2' '1' '1' '7' '0' '6' '7' p = 0 s = '820974944592307816406286208998628034825342117067' s = '20974944592307816406286208998628034825342117067' s = '0974944592307816406286208998628034825342117067' s = ' 974944592307816406286208998628034825342117067' s = ' 74944592307816406286208998628034825342117067' s = ' 4944592307816406286208998628034825342117067' s = ' 944592307816406286208998628034825342117067' s = '  44592307816406286208998628034825342117067' s = '  4592307816406286208998628034825342117067' s = '  592307816406286208998628034825342117067' s = '  92307816406286208998628034825342117067' s = '   2307816406286208998628034825342117067' s = '   307816406286208998628034825342117067' s = '   07816406286208998628034825342117067' s = '    7816406286208998628034825342117067' s = '    816406286208998628034825342117067' s = '    16406286208998628034825342117067' s = '    6406286208998628034825342117067' s = '    406286208998628034825342117067' s = '    06286208998628034825342117067' s = '     6286208998628034825342117067' s = '     286208998628034825342117067' s = '     86208998628034825342117067' s = '     6208998628034825342117067' s = '     208998628034825342117067' s = '     08998628034825342117067' s = '      8998628034825342117067' s = '     998628034825342117067' s = '      98628034825342117067' s = '      8628034825342117067' s = '      628034825342117067' s = '      28034825342117067' s = '      8034825342117067' s = '      034825342117067' s = '       34825342117067' s = '       4825342117067' s = '       825342117067' s = '       25342117067' s = '       5342117067' s = '       342117067' s = '       42117067' s = '       2117067' s = '       117067' s = '       17067' s = '       7067' s = '       067' s = '        67' s = '        7' s = '        ' p = 0 p = 0 0 p = 0 0 0 p = 0 0 0 0 p = 0 0 0 0 9072 p = 0 0 0 0 9072 4032 p = 0 0 0 0 9072 4032 2880 p = 0 0 0 0 9072 4032 2880 6480 p = 0 0 0 0 9072 4032 2880 6480 1440 p = 0 0 0 0 9072 4032 2880 6480 1440 1080 p = 0 0 0 0 9072 4032 2880 6480 1440 1080 0 p = 0 0 0 0 9072 4032 2880 6480 1440 1080 0 0 p = 0 0 0 0 9072 4032 2880 6480 1440 1080 0 0 0 p = 0 0 0 0 9072 4032 2880 6480 1440 1080 0 0 0 0 p = Columns 1 through 14 0 0 0 0 9072 4032 2880 6480 1440 1080 0 0 0 0 Column 15 0 p = Columns 1 through 14 0 0 0 0 9072 4032 2880 6480 1440 1080 0 0 0 0 Columns 15 through 16 0 1344 p = Columns 1 through 14 0 0 0 0 9072 4032 2880 6480 1440 1080 0 0 0 0 Columns 15 through 17 0 1344 0 p = Columns 1 through 14 0 0 0 0 9072 4032 2880 6480 1440 1080 0 0 0 0 Columns 15 through 18 0 1344 0 0 p = Columns 1 through 14 0 0 0 0 9072 4032 2880 6480 1440 1080 0 0 0 0 Columns 15 through 19 0 1344 0 0 0 p = Columns 1 through 14 0 0 0 0 9072 4032 2880 6480 1440 1080 0 0 0 0 Columns 15 through 20 0 1344 0 0 0 0 p = Columns 1 through 14 0 0 0 0 9072 4032 2880 6480 1440 1080 0 0 0 0 Columns 15 through 21 0 1344 0 0 0 0 0 p = Columns 1 through 14 0 0 0 0 9072 4032 2880 6480 1440 1080 0 0 0 0 Columns 15 through 22 0 1344 0 0 0 0 0 1152 p = Columns 1 through 14 0 0 0 0 9072 4032 2880 6480 1440 1080 0 0 0 0 Columns 15 through 23 0 1344 0 0 0 0 0 1152 0 p = Columns 1 through 14 0 0 0 0 9072 4032 2880 6480 1440 1080 0 0 0 0 Columns 15 through 24 0 1344 0 0 0 0 0 1152 0 0 p = Columns 1 through 14 0 0 0 0 9072 4032 2880 6480 1440 1080 0 0 0 0 Columns 15 through 25 0 1344 0 0 0 0 0 1152 0 0 0 p = Columns 1 through 14 0 0 0 0 9072 4032 2880 6480 1440 1080 0 0 0 0 Columns 15 through 26 0 1344 0 0 0 0 0 1152 0 0 0 0 p = Columns 1 through 14 0 0 0 0 9072 4032 2880 6480 1440 1080 0 0 0 0 Columns 15 through 27 0 1344 0 0 0 0 0 1152 0 0 0 0 0 p = Columns 1 through 14 0 0 0 0 9072 4032 2880 6480 1440 1080 0 0 0 0 Columns 15 through 28 0 1344 0 0 0 0 0 1152 0 0 0 0 0 31104 p = Columns 1 through 14 0 0 0 0 9072 4032 2880 6480 1440 1080 0 0 0 0 Columns 15 through 28 0 1344 0 0 0 0 0 1152 0 0 0 0 0 31104 Column 29 7776 p = Columns 1 through 14 0 0 0 0 9072 4032 2880 6480 1440 1080 0 0 0 0 Columns 15 through 28 0 1344 0 0 0 0 0 1152 0 0 0 0 0 31104 Columns 29 through 30 7776 6912 p = Columns 1 through 14 0 0 0 0 9072 4032 2880 6480 1440 1080 0 0 0 0 Columns 15 through 28...

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

bla = 1×51 cell array Columns 1 through 25 '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' Columns 26 through 50 '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' Column 51 '9' p = 0 s = '41592653589793238462643383279502884197169399399999' s = '1592653589793238462643383279502884197169399399999' s = '592653589793238462643383279502884197169399399999' s = '92653589793238462643383279502884197169399399999' s = ' 2653589793238462643383279502884197169399399999' s = ' 653589793238462643383279502884197169399399999' s = ' 53589793238462643383279502884197169399399999' s = ' 3589793238462643383279502884197169399399999' s = ' 589793238462643383279502884197169399399999' s = ' 89793238462643383279502884197169399399999' s = ' 9793238462643383279502884197169399399999' s = '  793238462643383279502884197169399399999' s = '  93238462643383279502884197169399399999' s = '   3238462643383279502884197169399399999' s = '   238462643383279502884197169399399999' s = '   38462643383279502884197169399399999' s = '   8462643383279502884197169399399999' s = '   462643383279502884197169399399999' s = '   62643383279502884197169399399999' s = '   2643383279502884197169399399999' s = '   643383279502884197169399399999' s = '   43383279502884197169399399999' s = '   3383279502884197169399399999' s = '   383279502884197169399399999' s = '   83279502884197169399399999' s = '   3279502884197169399399999' s = '   279502884197169399399999' s = '   79502884197169399399999' s = '   9502884197169399399999' s = '    502884197169399399999' s = '    02884197169399399999' s = '     2884197169399399999' s = '     884197169399399999' s = '     84197169399399999' s = '    4197169399399999' s = '    197169399399999' s = '    97169399399999' s = '     7169399399999' s = '     169399399999' s = '     69399399999' s = '     9399399999' s = '      399399999' s = '      99399999' s = '       9399999' s = '       399999' s = '       99999' s = '        9999' s = '        999' s = '        99' s = '        9' s = '        ' p = 180 p = 180 360 p = 180 360 540 p = 180 360 540 2700 p = 180 360 540 2700 1620 p = 180 360 540 2700 1620 900 p = 180 360 540 2700 1620 900 3600 p = 180 360 540 2700 1620 900 3600 5400 p = 180 360 540 2700 1620 900 3600 5400 7560 p = 180 360 540 2700 1620 900 3600 5400 7560 22680 p = 180 360 540 2700 1620 900 3600 5400 7560 22680 13608 p = 180 360 540 2700 1620 900 3600 5400 7560 22680 13608 3402 p = 180 360 540 2700 1620 900 3600 5400 7560 22680 13608 3402 1134 p = 180 360 540 2700 1620 900 3600 5400 7560 22680 13608 3402 1134 1296 p = Columns 1 through 14 180 360 540 2700 1620 900 3600 5400 7560 22680 13608 3402 1134 1296 Column 15 576 p = Columns 1 through 14 180 360 540 2700 1620 900 3600 5400 7560 22680 13608 3402 1134 1296 Columns 15 through 16 576 1152 p = Columns 1 through 14 180 360 540 2700 1620 900 3600 5400 7560 22680 13608 3402 1134 1296 Columns 15 through 17 576 1152 1152 p = Columns 1 through 14 180 360 540 2700 1620 900 3600 5400 7560 22680 13608 3402 1134 1296 Columns 15 through 18 576 1152 1152 2304 p = Columns 1 through 14 180 360 540 2700 1620 900 3600 5400 7560 22680 13608 3402 1134 1296 Columns 15 through 19 576 1152 1152 2304 1152 p = Columns 1 through 14 180 360 540 2700 1620 900 3600 5400 7560 22680 13608 3402 1134 1296 Columns 15 through 20 576 1152 1152 2304 1152 864 p = Columns 1 through 14 180 360 540 2700 1620 900 3600 5400 7560 22680 13608 3402 1134 1296 Columns 15 through 21 576 1152 1152 2304 1152 864 432 p = Columns 1 through 14 180 360 540 2700 1620 900 3600 5400 7560 22680 13608 3402 1134 1296 Columns 15 through 22 576 1152 1152 2304 1152 864 432 1728 p = Columns 1 through 14 180 360 540 2700 1620 900 3600 5400 7560 22680 13608 3402 1134 1296 Columns 15 through 23 576 1152 1152 2304 1152 864 432 1728 864 p = Columns 1 through 14 180 360 540 2700 1620 900 3600 5400 7560 22680 13608 3402 1134 1296 Columns 15 through 24 576 1152 1152 2304 1152 864 432 1728 864 432 p = Columns 1 through 14 180 360 540 2700 1620 900 3600 5400 7560 22680 13608 3402 1134 1296 Columns 15 through 25 576 1152 1152 2304 1152 864 432 1728 864 432 1008 p = Columns 1 through 14 180 360 540 2700 1620 900 3600 5400 7560 22680 13608 3402 1134 1296 Columns 15 through 26 576 1152 1152 2304 1152 864 432 1728 864 432 1008 3024 p = Columns 1 through 14 180 360 540 2700 1620 900 3600 5400 7560 22680 13608 3402 1134 1296 Columns 15 through 27 576 1152 1152 2304 1152 864 432 1728 864 432 1008 3024 1890 p = Columns 1 through 14 180 360 540 2700 1620 900 3600 5400 7560 22680 13608 3402 1134 1296 Columns 15 through 28 576 1152 1152 2304 1152 864 432 1728 864 432 1008 3024 1890 0 p = Columns 1 through 14 180 360 540 2700 1620 900 3600 5400 7560 22680 13608 3402 1134 1296 Columns 15 through 28 576 1152 1152 2304 1152 864 432 1728 864 432 1008 3024 1890 0 Column 29 0 p = Columns 1 through 14 180 360 540 2700 1620 900 3600 5400 7560 22680 13608 3402 1134 1296 Columns 15 through 28 576 1152 1152 2304 1152 864 43...

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

bla = 1×58 cell array Columns 1 through 25 '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' Columns 26 through 50 '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' Columns 51 through 58 '3' '6' '0' '7' '2' '6' '0' '2' p = 0 s = '831652712019091456485669234603486104543266482133936072602' s = '31652712019091456485669234603486104543266482133936072602' s = '1652712019091456485669234603486104543266482133936072602' s = '652712019091456485669234603486104543266482133936072602' s = '52712019091456485669234603486104543266482133936072602' s = '2712019091456485669234603486104543266482133936072602' s = '712019091456485669234603486104543266482133936072602' s = '12019091456485669234603486104543266482133936072602' s = '2019091456485669234603486104543266482133936072602' s = '019091456485669234603486104543266482133936072602' s = ' 19091456485669234603486104543266482133936072602' s = ' 9091456485669234603486104543266482133936072602' s = '  091456485669234603486104543266482133936072602' s = '  91456485669234603486104543266482133936072602' s = '  1456485669234603486104543266482133936072602' s = '  456485669234603486104543266482133936072602' s = '  56485669234603486104543266482133936072602' s = '  6485669234603486104543266482133936072602' s = '  485669234603486104543266482133936072602' s = '  85669234603486104543266482133936072602' s = '  5669234603486104543266482133936072602' s = '  669234603486104543266482133936072602' s = '  69234603486104543266482133936072602' s = '  9234603486104543266482133936072602' s = '   234603486104543266482133936072602' s = '   34603486104543266482133936072602' s = '   4603486104543266482133936072602' s = '   603486104543266482133936072602' s = '   03486104543266482133936072602' s = '    3486104543266482133936072602' s = '    486104543266482133936072602' s = '    86104543266482133936072602' s = '    6104543266482133936072602' s = '    104543266482133936072602' s = '    04543266482133936072602' s = '     4543266482133936072602' s = '     543266482133936072602' s = '     43266482133936072602' s = '     3266482133936072602' s = '     266482133936072602' s = '     66482133936072602' s = '     6482133936072602' s = '     482133936072602' s = '     82133936072602' s = '     2133936072602' s = '     133936072602' s = '     33936072602' s = '     3936072602' s = '     936072602' s = '      36072602' s = '      6072602' s = '      072602' s = '       72602' s = '       2602' s = '       602' s = '       02' s = '        2' s = '        ' p = 1008 p = 1008 720 p = 1008 720 180 p = 1008 720 180 420 p = 1008 720 180 420 420 p = 1008 720 180 420 420 140 p = 1008 720 180 420 420 140 0 p = 1008 720 180 420 420 140 0 0 p = 1008 720 180 420 420 140 0 0 0 p = 1008 720 180 420 420 140 0 0 0 0 p = 1008 720 180 420 420 140 0 0 0 0 0 p = 1008 720 180 420 420 140 0 0 0 0 0 0 p = 1008 720 180 420 420 140 0 0 0 0 0 0 0 p = 1008 720 180 420 420 140 0 0 0 0 0 0 0 0 p = Columns 1 through 14 1008 720 180 420 420 140 0 0 0 0 0 0 0 0 Column 15 1080 p = Columns 1 through 14 1008 720 180 420 420 140 0 0 0 0 0 0 0 0 Columns 15 through 16 1080 480 p = Columns 1 through 14 1008 720 180 420 420 140 0 0 0 0 0 0 0 0 Columns 15 through 17 1080 480 3840 p = Columns 1 through 14 1008 720 180 420 420 140 0 0 0 0 0 0 0 0 Columns 15 through 18 1080 480 3840 4800 p = Columns 1 through 14 1008 720 180 420 420 140 0 0 0 0 0 0 0 0 Columns 15 through 19 1080 480 3840 4800 5760 p = Columns 1 through 14 1008 720 180 420 420 140 0 0 0 0 0 0 0 0 Columns 15 through 20 1080 480 3840 4800 5760 5760 p = Columns 1 through 14 1008 720 180 420 420 140 0 0 0 0 0 0 0 0 Columns 15 through 21 1080 480 3840 4800 5760 5760 12960 p = Columns 1 through 14 1008 720 180 420 420 140 0 0 0 0 0 0 0 0 Columns 15 through 22 1080 480 3840 4800 5760 5760 12960 3240 p = Columns 1 through 14 1008 720 180 420 420 140 0 0 0 0 0 0 0 0 Columns 15 through 23 1080 480 3840 4800 5760 5760 12960 3240 1944 p = Columns 1 through 14 1008 720 180 420 420 140 0 0 0 0 0 0 0 0 Columns 15 through 24 1080 480 3840 4800 5760 5760 12960 3240 1944 1296 p = Columns 1 through 14 1008 720 180 420 420 140 0 0 0 0 0 0 0 0 Columns 15 through 25 1080 480 3840 4800 5760 5760 12960 3240 1944 1296 1296 p = Columns 1 through 14 1008 720 180 420 420 140 0 0 0 0 0 0 0 0 Columns 15 through 26 1080 480 3840 4800 5760 5760 12960 3240 1944 1296 1296 0 p = Columns 1 through 14 1008 720 180 420 420 140 0 0 0 0 0 0 0 0 Columns 15 through 27 1080 480 3840 4800 5760 5760 12960 3240 1944 1296 1296 0 0 p = Columns 1 through 14 1008 720 180 420 420 140 0 0 0 0 0 ...

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

bla = 1×68 cell array Columns 1 through 25 '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' Columns 26 through 50 '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' Columns 51 through 68 '9' '0' '3' '6' '0' '0' '1' '1' '3' '3' '0' '5' '3' '0' '5' '4' '8' '8' p = 0 s = '0066063155881748815209209628292540917153643678925903600113305305488' s = ' 066063155881748815209209628292540917153643678925903600113305305488' s = ' 66063155881748815209209628292540917153643678925903600113305305488' s = ' 6063155881748815209209628292540917153643678925903600113305305488' s = ' 063155881748815209209628292540917153643678925903600113305305488' s = '  63155881748815209209628292540917153643678925903600113305305488' s = '  3155881748815209209628292540917153643678925903600113305305488' s = '  155881748815209209628292540917153643678925903600113305305488' s = '  55881748815209209628292540917153643678925903600113305305488' s = '  5881748815209209628292540917153643678925903600113305305488' s = '  881748815209209628292540917153643678925903600113305305488' s = '  81748815209209628292540917153643678925903600113305305488' s = '  1748815209209628292540917153643678925903600113305305488' s = '  748815209209628292540917153643678925903600113305305488' s = '  48815209209628292540917153643678925903600113305305488' s = '  8815209209628292540917153643678925903600113305305488' s = '  815209209628292540917153643678925903600113305305488' s = '  15209209628292540917153643678925903600113305305488' s = '  5209209628292540917153643678925903600113305305488' s = '  209209628292540917153643678925903600113305305488' s = '  09209628292540917153643678925903600113305305488' s = '   9209628292540917153643678925903600113305305488' s = '   209628292540917153643678925903600113305305488' s = '   09628292540917153643678925903600113305305488' s = '    9628292540917153643678925903600113305305488' s = '    628292540917153643678925903600113305305488' s = '    28292540917153643678925903600113305305488' s = '    8292540917153643678925903600113305305488' s = '    292540917153643678925903600113305305488' s = '    92540917153643678925903600113305305488' s = '     2540917153643678925903600113305305488' s = '     540917153643678925903600113305305488' s = '     40917153643678925903600113305305488' s = '     0917153643678925903600113305305488' s = '      917153643678925903600113305305488' s = '      17153643678925903600113305305488' s = '      7153643678925903600113305305488' s = '      153643678925903600113305305488' s = '      53643678925903600113305305488' s = '      3643678925903600113305305488' s = '      643678925903600113305305488' s = '      43678925903600113305305488' s = '      3678925903600113305305488' s = '      678925903600113305305488' s = '      78925903600113305305488' s = '      8925903600113305305488' s = '      925903600113305305488' s = '       25903600113305305488' s = '       5903600113305305488' s = '       903600113305305488' s = '        03600113305305488' s = '        3600113305305488' s = '        600113305305488' s = '        00113305305488' s = '         0113305305488' s = '         113305305488' s = '         13305305488' s = '         3305305488' s = '         305305488' s = '         05305488' s = '          5305488' s = '          305488' s = '          05488' s = '           5488' s = '           488' s = '           88' s = '           8' s = '           ' p = 0 p = 0 0 p = 0 0 0 p = 0 0 0 0 p = 0 0 0 0 0 p = 0 0 0 0 0 0 p = 0 0 0 0 0 0 450 p = 0 0 0 0 0 0 450 600 p = 0 0 0 0 0 0 450 600 1600 p = 0 0 0 0 0 0 450 600 1600 1600 p = 0 0 0 0 0 0 450 600 1600 1600 2240 p = 0 0 0 0 0 0 450 600 1600 1600 2240 1792 p = 0 0 0 0 0 0 450 600 1600 1600 2240 1792 1792 p = 0 0 0 0 0 0 450 600 1600 1600 2240 1792 1792 1792 p = Columns 1 through 14 0 0 0 0 0 0 450 600 1600 1600 2240 1792 1792 1792 Column 15 1792 p = Columns 1 through 14 0 0 0 0 0 0 450 600 1600 1600 2240 1792 1792 1792 Columns 15 through 16 1792 1280 p = Columns 1 through 14 0 0 0 0 0 0 450 600 1600 1600 2240 1792 1792 1792 Columns 15 through 17 1792 1280 640 p = Columns 1 through 14 0 0 0 0 0 0 450 600 1600 1600 2240 1792 1792 1792 Columns 15 through 18 1792 1280 640 0 p = Columns 1 through 14 0 0 0 0 0 0 450 600 1600 1600 2240 1792 1792 1792 Columns 15 through 19 1792 1280 640 0 0 p = Columns 1 through 14 0 0 0 0 0 0 450 600 1600 1600 2240 1792 1792 1792 Columns 15 through 20 1792 1280 640 0 0 0 p = Columns 1 through 14 0 0 0 0 0 0 450 600 1600 1600 2240 1792 1792 1792 Columns 15 through 21 1792 1280 640 0 0 0 0 p = Columns 1 through 14 0 0 0 0 0 0 450 600 1600 1600 2240 1792 1792 1792 Columns 15 through 22 1792 1280 640 0 0 0 0 0 p = Columns 1 through 14 0 0 0 0 0 0 450 600 1600 1600 2240 1792 1792 1792 Columns 15 through 23 1792 1280 640 0 0 0 0 0 0 p = Columns 1 through 14 0 0 0 0 0 0 450 600 1600 1600 2240 1792 1792 1792 Columns 15 through 24 1792 1280 640 0 0 0 0 0 0 0 p = Columns 1 through 14 0 0 0 0 0 0 450 600 1600 1600 2240 1792 1792 1792 Columns 15 through 25 1792 1280 640 0 0 0 0 ...

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

bla = 1×5 cell array '1' '1' '1' '1' '1' p = 0 s = '1111' s = '111' s = '11' s = '1' s = '' p = 1 m = 1 idx = 1

Suggested Problems

More from this Author95