Euleryx Problem 8 - Largest Product in a Series
My workflow and answer:
Answer: 23514624000
Last Weeks Favourite Solution:
Another tough decision but, with a macro free solution that ran in under 1 second, @AkimasaKajitani's solution leveraging a generate rows has won this weeks award. The generate rows doesn't just check for factors but is even able to tag the prime numbers with a "-1", all in a singular tool. If you want to check you this solution, please view it on page one of last weeks post or by clicking here.
Mathematical Theory – The Truth
Yes, throughout this series, my intention was to try and solve these problems using some form of mathematical theory to help optimise the solution. However, problem 8 has got me stumped. Whilst there are some time-saving techniques we could use, such as ignoring any groups that contain a 0 (as their product will just = 0), I could not think of any significant theories to apply here.
On the bright side, this does give me the opportunity to join Team Brute Force! If you are still interested, here's how I tackled the problem.
Method:
As with any problem, no matter what approach you take, you need an input to begin. In this case, I pasted the 1000-digit number into the text input tool, then began to solve the problem:
1) Use Regex to remove new lines and then tokenise the number to get one digit per line.
2) Create a Record ID and then generate 13 rows per digit. (If we are creating groups of 13 consecutive numbers, each digit will appear in up to 13 groups).
3) Create Group IDs. Now we have 13 copies of each digit, we can allocate their groups based on their Record ID and RowCount.
4) Find the product per group, and filter to groups with 13 digits only (full groups).
5) Sort descending and sample your top answer.
6) Submit your answer to the Project Euler Website!
Summary:
Despite taking a different approach from usual, we have arrived at a solution that not only runs but takes just 0.3 seconds.
With it being so quick, I'd like to think this was still an effective method, please share your thoughts below!
Want to find out more, follow this link to our introduction post - Euleryx: Let The Games Begin.
Nothing a little tokenize and multirow can't solve...
Solved in Designer Cloud again! Can't beat the instant gratification of seeing your changes without having to hit Run!
