So a big part of all this Project Euler nonsense includes prime numbers. Problem 10, begs the ever-so-common question Find the sum of all the primes below one million. Obviously, the first attempt would be to just straight out calculate it using my previous program in Problem 3. Adapting that program to one million integers resulted in about 768 seconds (read: over 10 minutes) of time. Obviously this breaks the 1 minute rule the program needed to be tweaked.

Trying other various methods I still came up short with the result being about 176 seconds at best. To optimize my program I was mainly looking for some information on how prime numbers might be related to bits/bytes to see if I could perhaps try some bitwise operations to speed things up. In doing so, I came across an article suggesting that having an array of bits (essentially a long char) with each char representing a number in an array from 0 to x; x being the limit. Once this array was created, simply just iterate from 0 to the square root of your limit, and mark all multiples of any primes found on your way. Makes sense - and this greatly cuts down on all the harsh prime calculating going on in the background.
(more...)

So as many already probably know Euler was a famous European mathematician and physicist. Recently at work a lot of talk has been going around about Project Euler; basically a website which poses mathematical problems that need to be solved by writing program. So a few of us at work have decided to take the plunge and learn a completely new language while attempting to answer some of these questions.

So I guess I should start with saying I'll be using/learning Python for all of my problems. Not a terribly hard choice as I'm already pretty familiar with Perl and PHP which seem to be somewhat similar to Python. Anyways, if anyone else wants to get in on the fun. Feel free to do so and post links to your own blogs/solutions or simply just put them here! I plan on using these solutions as an excuse to actually get posting more on here. So, we'll see how that goes. I may also have to make some sort of hiding script so solutions aren't completely revealed to those that want to accomplish everything on their own. Without further adieu - the first 3 problems and my solutions. (more...)

So I decided on a theme. Feel free to leave comments on it! I'm pretty pleased with how it turned out.

Today I also ended up setting up my webfaction account with a few friends of mine. We mainly decided to move there because of dreamhost's policy against long running processes. Don't get me wrong! Dreamhost is a dream hosting company with super cheap plans with tons of storage and bandwidth. But myself and some of my friends have taken quite an interest in learning python as of late. It seems a lot of their web frameworks (mainly pylons and django) involve running some sort of python WSGI "middleware" to communicate between webservers and the actual web applications. At any rate, this was a nightmare to try and get running properly dreamhost. Webfaction seems to be more than python friendly, so we'll see how it goes!

Alright, here's attempt number... well I've lost count. Hopefully I'll be doing some more development in my free time which! could possibly lead to more blogs! If all goes well, I can keep this site from going the way of the dinosaurs. Which leads me to my first task! Making some sort of logo to replace the lame standard one.

« Previous Page