Cody

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

Solution 718705

Submitted on 20 Aug 2015 by Ian Riley
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))

prod = 344362200 prod = 365445600 prod = 372754512 prod = 365445600 prod = 344362200

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

prod = 406022400 prod = 421344000 prod = 391248000 prod = 446022720 prod = 483191280 prod = 440806080 prod = 424776768 prod = 465620688 prod = 408439200 prod = 400584600 prod = 369770400 prod = 383724000 prod = 376992000 prod = 369452160 prod = 391184640 prod = 423783360 prod = 369847296 prod = 356638464 prod = 363916800 prod = 377395200 prod = 391910400 prod = 408240000 prod = 362880000 prod = 406425600 prod = 413683200 prod = 436665600 prod = 489065472 prod = 550198656 prod = 491248800 prod = 482630400 prod = 406425600 prod = 370137600 prod = 356428800 prod = 399200256 prod = 356428800 prod = 393556800 prod = 393556800 prod = 393556800 prod = 351390000 prod = 344362200 prod = 318372600 prod = 343343000 prod = 316932000 prod = 342286560 prod = 384199200

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

prod = 377177892 prod = 384875400 prod = 399678300 prod = 432305100 prod = 415991700 prod = 386799300 prod = 433215216 prod = 457282728 prod = 474538680 prod = 530366760 prod = 510352920 prod = 455672250 prod = 407706750 prod = 415119600 prod = 378705600 prod = 400982400 prod = 400982400 prod = 424569600 prod = 394243200 prod = 386661600 prod = 365180400 prod = 409002048 prod = 386279712 prod = 371422800 prod = 400554000 prod = 447678000 prod = 423695250 prod = 398772000 prod = 398772000 prod = 406022400 prod = 398899200 prod = 391372800 prod = 399526400 prod = 455460096 prod = 447326880 prod = 391411020 prod = 406465290 prod = 472826970 prod = 423055710 prod = 438439554 prod = 510021522 prod = 481686993 prod = 481686993 prod = 538356051 prod = 538356051 prod = 538356051 prod = 601692057

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

prod = 415633680 prod = 400519728 prod = 357606900 prod = 385654500 prod = 385654500 prod = 357087500 prod = 323400000 prod = 316932000 prod = 328456800 prod = 321753600 prod = 366799104 prod = 374440752 prod = 397365696 prod = 369480384 prod = 415665432 prod = 379203552 prod = 433375488 prod = 441709632 prod = 450043776 prod = 450043776 prod = 493317216 prod = 440461800 prod = 423840600 prod = 408142800 prod = 408142800 prod = 343699200 prod = 350573184 prod = 357447168 prod = 384943104 prod = 384943104 prod = 392962752 prod = 369847296 prod = 369847296 prod = 350034048 prod = 337069824 prod = 350827776 prod = 365445600 prod = 379501200 prod = 386661600 prod = 386661600 prod = 424569600 prod = 424569600 prod = 385257600 prod = 363854400 prod = 356857200 prod = 363229650 prod = 370494243 prod = 408299778 prod = 384282144 prod = 414421920 prod = 363528000 prod = 384912000 prod = 342144000 prod = 356400000

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

prod = 369515520 prod = 322486272 prod = 362797056 prod = 385471872 prod = 349780032 prod = 343302624 prod = 379063314 prod = 393102696 prod = 431642176 prod = 431642176 prod = 447930560 prod = 439479040 prod = 439479040 prod = 439479040 prod = 439479040 prod = 423497984 prod = 407209600 prod = 349036800 prod = 355269600 prod = 362520000 prod = 328320000 prod = 374284800 prod = 421070400 prod = 369360000 prod = 413683200 prod = 430920000 prod = 430920000 prod = 399000000 prod = 422940000 prod = 392730000 prod = 377020800 prod = 377020800 prod = 369480384 prod = 383423040 prod = 361302480 prod = 398938155 prod = 356944665 prod = 393367590 prod = 371911176 prod = 387091224 prod = 394394832 prod = 425327760 prod = 441080640 prod = 483492240 prod = 474012000 prod = 465234000 prod = 482151600 prod = 413272800 prod = 369770400 prod = 399352032 prod = 361677312 prod = 304570368 prod = 310915584 prod = 298722816 prod = 282127104 prod = 299760048 prod = 299760048 prod = 324230256 prod = 337464144 prod = 317613312 prod = 330068736 prod = 357574464 prod = 377814528 prod = 414855168

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

prod = 282475249