We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Project Euler #88: Product-sum numbers
Project Euler #88: Product-sum numbers
Sort by
recency
|
15 Discussions
|
Please Login in order to post a comment
Easy, are you sure? It took me five weeks. Not full time of course.
The bounds for N are way higher here than on project Euler. Never the less it is possible even in Python to compute the whole thing in the time alotted. In my loop to consider all products I only needed to keep track of three numbers for each element in the queue: the product the sum and the largest factor in the current product. All products can then be generated recursively by condidering previous products and multiplying by a new number of value greater than or equal to what was previously the largest factor. Since 2k is always a product for k of length k i.e. 1*1*....*1*2*k=1+...+1+2+k when we have k-2 ones, the univeral bound for products is 2N.
Is there any non-recursive approach out there? The recursive version loops through candidates in such a way that answers are updated occasionally (an answer you find midway might be replaced by another at the end of the day).
I tried to use a
dequeue
andset
to generate multiplicative partitions (based on a list of primitive factors) of ascendingn
, and whenever any answer is found it is guaranteed to be one of the final answers. It seems to be correct but was too slow for half of the test cases. I don't know if it is because of the algorithm itself which is poor in nature, or the extensive use and manipulation oflist
andset
in this case.This is the difference between constructing products from ascending factors and constructing factors from ascending products. Well, after all the former approach sounds a lot more straightforward.
This source may HELP https://mail.google.com/mail/u/0/?ui=2&ik=3e125a257a&view=att&th=16173693abe9a47c&attid=0.1&disp=safe&realattid=1591800991683969024-local0&zw
Keep coding:)