View Single Post
Old 10-23-2011, 06:21 PM   #45
stargroup100
behanjc & me are <3'ers
FFR Simfile AuthorFFR Music Producer
 
Join Date: Jul 2006
Posts: 2,051
Default Re: THE project euler thread

Your solution is too linear. You should take into consideration the possible case that immediately adding the largest possible number won't optimize the overall total.

It's possible there is a different combination of the primes that rounds out to a better sum. I recommend this method:

- Separate primes into 3 categories: between 2 and sqrt(n), between sqrt(n) and n/2, and the others
- Add up all of the primes in the last category. These don't change.
- The terms in the second category have the most room for possible optimizations, and therefore should try to be optimized first. They obviously cannot be paired with a prime from its own category, so pair it with a prime from the first category. Try every combination here.
- The last possible case is that 2 primes from the first category might be paired together. Consider this generalization last.

Do it this way and see if you can get to 1356.


NOTE: I'm not sure if the last step is necessary, I'm trying to see if I can prove whether or not that last step is needed.
__________________
Rhythm Simulation Guide
Comments, criticism, suggestions, contributions, etc. are all welcome.

Piano Etude Demon Fire sheet music
stargroup100 is offline   Reply With Quote