Project Euler

For a long time I have wanted to improve my programming skills. Well, skills might be a overstatement. I have had two short introductory programming courses during my many years at uni, one C++ and one Java. But after the course is over I stop programming, since there are no more hand-ins, and as a result I quickly forget even the basics.

So now my hope is that if I spend one or two hours a week working with some problems (with a math twist to keep my focus) I will pick up the basics and get more familiar with Java (the programming language that I have chosen to start out with).

So I have started working the problems at Project Euler. I haven’t spend that much time working the problems yet, but I have solved the first two (using very brute force and non-elegant code), but it seems I have to do a bit of thinking for the third problem. Somehow working through all the integers from one to 600,851,475,143, check if they are a factor of 600,851,475,143 and then check if that factor is a prime is not the most optimal way to find the largest prime factor of 600,851,475,143. Back to the drawing board…

Of course I could ‘cheat’ and just do

$ factor 600851475143

in a shell, but that way I won’t learn much…

leonhard_euler

I first heard about Project Euler at the xkcd blag, but haven’t had the time to look into it before now.

If you know of other interesting problems useful for brushing up on a programming language, feel free to leave a comment.

And before I forget, a big thanks goes out to Søren, who has been very patient with my basic questions like “how do I check if one or the other condition is fulfilled in my if statement?”. I promise, I’ll pick up a book soon and stop bothering you with trivialities on chat!

7 thoughts on “Project Euler”

  1. You could have a look at usaco.org or more precisely at train.usaco.org that is a gateway into trying out the exercises (you have to register so it can track your progress).
    I don’t remember if you can submit solutions in java though.

  2. I like Code Kata (http://codekata.pragprog.com/)
    They tend to be more real-world problems (and therefore expand into other areas of the language), whereas I’ve found Euler more useful for brushing up my maths than my code. I like to use them when coming up to speed in a new language.

    The only problem is that no solutions are on the site. It’s more of a practice set – figure it out, then come back some time later and figure it out again, with any new knowledge you’ve gained.

  3. Hello,

    Good luck with Project Euler, but keep in mind that the prime related problems are much easier if you studied Z/nZ and some of them require actual maths :P

    I registered to Project Euler quite a while ago, and there are a lot of problems for which i’m epicly failing at finding a good approach (and i don’t have much time either..).

    Also, let me recommand you to try to code in Scheme or Lisp, once you get used to the specificity of those languages, they’re really nice for writing basic algorithms (but not very efficient in terms of performances :p).

  4. Hey

    Yeah, it’s nice training, but as others have already mentioned, it’s at least as much about polishing math skills, as it is for programming skills. But with your line of hobbies that shouldn’t be a problem.
    Though if you were a bit awake, you’d notice that I already told you about Project Euler last september :-)

    Jesper

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.