Is there a design pattern that lends itself to building a foundation of components to help solve Project Euler problems? I've solved ~30 issues - and I find that I'll need to re-use functionality that was previously written (e.g primality checks). Instead of writing static methods in a utility class, I was thinking of having a calculator interface - implemented by various concrete classes that will solve different sub problems. I could then build on that as I solve increasingly complex problems - maybe? Does anyone have any good suggestions? I'm solving the problems in Java.
There are some functions that come in handy repeatedly, like for generating primes. You could keep a file with useful functions in them. Beyond that I don't think there is any benefit. Project Euler problems are more about the math than they are about complex programming, I expect that if you have to write a lot of code you are doing it wrong.
The classic pattern for this kind of things is the Template design pattern, but you can build it thinking in other design patterns like for example Visitor, it depends on your needs and taste. You may find useful this link: Template method pattern
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With