Cody

# Problem 246. Project Euler: Problem 8, Find largest product in a large string of numbers

Solution 388888

Submitted on 21 Jan 2014 by Guillaume
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
%% a = ['73167176531330624919225119674426574742355349194934'... '96983520312774506326239578318016984801869478851843'... '85861560789112949495459501737958331952853208805511'... '12540698747158523863050715693290963295227443043557'... '66896648950445244523161731856403098711121722383113'... '62229893423380308135336276614282806444486645238749'... '30358907296290491560440772390713810515859307960866'... '70172427121883998797908792274921901699720888093776'... '65727333001053367881220235421809751254540594752243'... '52584907711670556013604839586446706324415722155397'... '53697817977846174064955149290862569321978468622482'... '83972241375657056057440261407972968652414535100474'... '82166370484403199890058895243450658541227588666881'... '16427171479924442928260863465674813919123162824586'... '17866458359124566529486545682848912883142607690042'... '24219022671055626321191109370544217506941658960408'... '07198403850962455444362981230987879927244284909188'... '84580156166097919133855499200524066689912560717606'... '05886116467109405077541002256983155200055935729725'... '71636269561882670428232483600823267530420752963450'] y_correct = 40824; assert(isequal(euler008(a),y_correct))

a = 7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843858615607891129494954595017379583319528532088055111254069874715852386305071569329096329522744304355766896648950445244523161731856403098711121722383113622298934233803081353362766142828064444866452387493035890729629049156044077239071381051585930796086670172427121883998797908792274921901699720888093776657273330010533678812202354218097512545405947522435258490771167055601360483958644670632441572215539753697817977846174064955149290862569321978468622482839722413756570560574402614079729686524145351004748216637048440319989005889524345065854122758866688116427171479924442928260863465674813919123162824586178664583591245665294865456828489128831426076900422421902267105562632119110937054421750694165896040807198403850962455444362981230987879927244284909188845801561660979191338554992005240666899125607176060588611646710940507754100225698315520005593572972571636269561882670428232483600823267530420752963450

2   Pass
%% a = ['73467176531330624919225119674426574742355349194934'... '96953520312774506326239578318016984801869478851843'... '85866560789112949495459501737958331952853208805511'... '12540898747158523863050715693290963295227443043557'... '66896698950445244523161731856403098711121722383113'... '62229890423380308135336276614282806444486645238749'... '30358907896290491560440772390713810515859307960866'... '70172427621883998797908792274921901699720888093776'... '65727333501053367881220235421809751254540594752243'... '52584907511670556013604839586446706324415722155397'... '53697817477846174064955149290862569321978468622482'... '83972241775657056057490261407972968652414535100474'... '82166370984403199890008895243450658541227588666881'... '16427171079924442928230863465674813919123162824586'... '17866458359124566529476545682848912883142607690042'... '24219022671055626321111109370544217506941658960408'... '07198403850962455444362981230987879927244284909188'... '84580156166097919133875499200524063689912560717606'... '05886116467109405077541002256983155200055935729725'... '71636269561882670428252483600823257530420752963450'] a = reshape(a,10,100); a = a'; a = a(:)'; y_correct = 35721; assert(isequal(euler008(a),y_correct))

a = 7346717653133062491922511967442657474235534919493496953520312774506326239578318016984801869478851843858665607891129494954595017379583319528532088055111254089874715852386305071569329096329522744304355766896698950445244523161731856403098711121722383113622298904233803081353362766142828064444866452387493035890789629049156044077239071381051585930796086670172427621883998797908792274921901699720888093776657273335010533678812202354218097512545405947522435258490751167055601360483958644670632441572215539753697817477846174064955149290862569321978468622482839722417756570560574902614079729686524145351004748216637098440319989000889524345065854122758866688116427171079924442928230863465674813919123162824586178664583591245665294765456828489128831426076900422421902267105562632111110937054421750694165896040807198403850962455444362981230987879927244284909188845801561660979191338754992005240636899125607176060588611646710940507754100225698315520005593572972571636269561882670428252483600823257530420752963450

3   Pass
%% a = ['05886116460109405000541002256983155200055935029025'... '96952652026120060506262622695082618016986080186960'... '85866560089112960960956059501026095826295208805511'... '12560089806001585226862605002629522060602606026550'... '66896698950526161026185660026098011121022268261126'... '62229890608026620661602828066060606086660522680609'... '26026589009156060600002269001268105158592600960866'... '00102602062699809090809220609219016990208880926006'... '65020262626501052626608812202265602180905125226026'... '52586090051160055601266060826958660606006261552690'... '52669081060008606106006609551609290862569266226082'... '82690226060506090261600090296865260160526510060060'... '82166260061998900088952602660506585601220588666881'... '16602010129282260862660656060812691912261628260586'... '10866605826591260566529600658912882616026006900602'... '26021902262626211111092600566021050696016589606008'... '00198600268509626055606060260809920260602860909188'... '86058015616609091912626805605640626689912560010606'... '05886116606010960050005601002251552000559265029025'... '01626626956188260060282526082668260602005296266050'] a = reshape(a,10,100); a = a'; a = a(:)'; y_correct = 31104; assert(isequal(euler008(a),y_correct))

a = 0588611646010940500054100225698315520005593502902596952652026120060506262622695082618016986080186960858665600891129609609560595010260958262952088055111256008980600158522686260500262952206060260602655066896698950526161026185660026098011121022268261126622298906080266206616028280660606060866605226806092602658900915606060000226900126810515859260096086600102602062699809090809220609219016990208880926006650202626265010526266088122022656021809051252260265258609005116005560126606082695866060600626155269052669081060008606106006609551609290862569266226082826902260605060902616000902968652601605265100600608216626006199890008895260266050658560122058866688116602010129282260862660656060812691912261628260586108666058265912605665296006589128826160260069006022602190226262621111109260056602105069601658960600800198600268509626055606060260809920260602860909188860580156166090919126268056056406266899125600106060588611660601096005000560100225155200055926502902501626626956188260060282526082668260602005296266050

### Community Treasure Hunt

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

Start Hunting!