Project Euler

Back in Newark

Friday, June 26th, 2009

I’ve now moved out of Stafford, need to go back this weekend to get the last of my things but that will be it then. As Tom mentioned in his blog we are all starting our placements soon. He is moving back across the country tomorrow to start on Monday, we don’t start for just over 3 weeks and moving to Munich in 2. It’s strange to think that we won’t be back at uni for a year. I’m still not spending my time doing anything constructive really, I probably should but I don’t really know what to do. I need to complete some games so I might do that, although I am needed to help build some steps in the garden so that might fill a few days.

A while ago I posted about Project Euler, I haven’t done any of the problems on there since about then so I might do that to get me back into a programming mind set before I start work. I haven’t really done any programming at all since we finished our assignments just after Easter, that’s nearly 2 months ago now.

I still intend to get myself a camera and take plenty of pictures while in Munich so some might find their way on here.

Tags: , ,

General, Project Euler, Uni Comments Off

Project Euler

Friday, April 3rd, 2009

I have recently been working through some of the problems on Project Euler. The site has a series of mathematical problems to solve. Each can be solved by writing a program to calculate the answer. An answer of one of the simpler problems is “Find the difference between the sum of the squares of the first one hundred natural numbers and the square of the sum.” and the solution is quite simple shown here in Python.

squareTotal=0

sumTotal=0

for num in range (1,101):

    sumTotal += num

    squareTotal += num*num

sumSquare = sumTotal*sumTotal

print sumSquare-squareTotal

Some of the problems are much more difficult however, they have a rule that all of the problems should be solvable on a modest PC in under a minute of computation. There are some that I have written where my first attempt would have taken several months to run but I have refined it down to about 10 minutes. There is a forum that you get access to once you have solved each problem. There are posts with other peoples’ solutions in a vast array of languages which can be quite interesting. That particular problem had a solution that ran in under 10 seconds.

There is well over 200 problems and rising so it should be enough to keep anyone busy for a while.  I will post any interesting solutions as I come across them.

Tags: ,