Project Euler

20 03 2009

I’ve recently come across a nifty page known as Project Euler. It’s filled with over 230 math related programming problems to solve. Don’t worry if your math is rusty, most of the problems can be brute forced easily enough, but knowing some math can certainly help make your programs faster. Trying to find all the divisors of a number for example, will crawl to a halt when you get to large numbers, but there’s a shortcut to find the result of the divisor function just by the prime factorization of a number. This will help solve one of the problems in about .8 seconds instead of about 20 minutes of computation.

Most of my solutions are very hacked together and brute force, but they work well enough. I’ve been focusing more on solving each problem quickly and correctly, rather than coming up with the best code, resulting in a lot of code that falls into the burn after compiling catagory. I’ve been doing most of them in C, but some I’ve resorted to Java and other languages to make things easier, or to reuse code (there’s one challenge to write a program to solve Su Doku puzzles, something I wrote in Java and mentioned here).

If I come up with a particularly ingenious solution to one of them I might post it here. I’m current finishing up the 14th problem (doing them mostly in order).



One response

21 03 2009

For the more recent problems, they are not brute-forcable.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: