Quick and dirty guide to getting started with Project Euler in C#

The solution has two projects: UI and Core.

UI is the webforms project that provides the multithreaded solution runner, and a handy output grid.

Core is independent of the UI project, and is just a collection of classes that implement the IProjectEulerProblem interface. If you wanted to start your own Project Euler instance, you should download all the source, but delete all the "ProblemXX.cs" files, and start creating your own ProblemXX files. If your classes implement the IProjectEulerProblem interface, the UI will automatically find them and add them to the runner for you.

Alternatively, you could use the IProjectEulerProblem interface, and write your own UI (console, WPF, ASP.NET, whatever you want).

There are three properties in IProjectEulerProblem:

int Number {get;}

This is simply the problem number. I just put "return 15;" or "return 23;" here and nothing else. You should put the Project Euler number here.

string Description {get;}

This is the label that will show up in the results grid. Put whatever you want. I usually try to put a short description, but you could just put "problem 15 answer" if you wanted to.

string Answer {get;}

This is the property that will be called to get the solution. This is where the actual "work" is done, and that's what each thread in the UI project will assume the "work" is. I usually keep the code here short, like "return FunctionToGetTheAnswer().ToString();" or similar.

That's it. Just start implementing IProjectEulerProblem and you're good to go.

Last edited Sep 19, 2010 at 4:57 AM by mattgroves, version 7


No comments yet.