Dead Men Walking

Forum Archive 2023 => dMw Gaming => Gaming Archive => It's a game ...but it ain't got its own topic! => Topic started by: Bob on July 01, 2008, 01:21:41 PM

Title: Project Euler
Post by: Bob on July 01, 2008, 01:21:41 PM
It is kind of a game, but not really either, more like a contest/competition or something - but this was the best suiting sub-forum I could think of. I'll start with a short quote from Project Euler's web page (http://projecteuler.net/):

QuoteWhat is Project Euler?

Project Euler is a series of challenging mathematical/computer programming problems that will require more than just mathematical insights to solve. Although mathematics will help you arrive at elegant and efficient methods, the use of a computer and programming skills will be required to solve most problems.

The motivation for starting Project Euler, and its continuation, is to provide a platform for the inquiring mind to delve into unfamiliar areas and learn new concepts in a fun and recreational context.
I came across this when watching and interview with Randall Munroe (creator of XKCD), where he mentioned this. I've always been interested in mathematics, and for a time I've wanted to find something I could fiddle with to increase my algorithm skills. I've also wanted to learn a new programming language (I went with Python), so after checking out the site, I found it to be the perfect thing for just that.

The problems range in difficulty. Examples are:When you submit the correct solution to a problem, you get access to a forum where people discuss different approaches to the problem. Quite many interesting algorithms are presented. People use almost any kind of programming language (anything from assembly, C/C++, Java, PHP, Haskell and J, just to mention a few) - but the common factor is, that given an efficiently implementation, the solution should be obtained in less than one minute.

I've been trying it our sporadically for some weeks now, and have currently solved 18 our of 200 problems (making me an 9% genius :49_49:). Anybody else find these kind of things interesting and entertaining?
Title: Project Euler
Post by: T-Bag on July 01, 2008, 02:40:10 PM
That sounds cool. My problem is my only "programming language" is Visual Basic. I'd like to learn another one, but it seems like quite a big challenge to take on myself. The "games" sound like something I would be able to manage too. If I do learn another language I would definately check this out.

[Edit] Ok, thinking about this a little more I've decided to put Visual Studio 2008 on (I got it free for being a student and thought I might aswell use it). I know that Microsoft Java isn't a good language to learn, so out of C# and C++ which would be best to learn?
(I'm doing a degree in Physics so if one has more powerful features but slightly harder to learn I'd rather put the effort it when first learning, that finding I need to mid-project - similarly if theres little difference between the two and one is harder, I'd rather not put the effort in in the first place)
Also if Microsoft is a bad route to go let me know because I'm only going with it because I already had it on my computer.
Title: Project Euler
Post by: Carr0t on July 01, 2008, 03:22:59 PM
Personally I found C# to be far easier to work with than C++, but I wasn't doing anything hugely maths intensive in either so I don't know which would be better for this kind of project.

Most of the hardcore maths dudes I know code in either Fortran (ewww, stay away) or Python (which I equally don't like, but none of my languages of choice are good for quick maths processing).
Title: Project Euler
Post by: Bob on July 01, 2008, 04:34:26 PM
Quote from: T-Bag;236229I know that Microsoft Java isn't a good language to learn, so out of C# and C++ which would be best to learn?
C# is easy to learn and work with - and it is also very similar to Java. So if you take time to learn one,  you'll also almost by default learn the other. J# you should for sure stay away from. C++ is definitely more powerful than C#, but the threshold to learn it is a bit higher.

Since you already have VS2008 (which also is a very nice IDE from what I've heard (I've only worked with VS2005 myself)), there is no reason not to go with C#. On the other hand, installing e.g. Eclipse or Netbeans and go with Java wouldn't be much more hassle.

Quote from: Carr0t;236233Most of the hardcore maths dudes I know code in either Fortran (ewww, stay away) or Python (which I equally don't like, but none of my languages of choice are good for quick maths processing).
The range of languages used by folks for the problems vary very much. The web page say that for any language, running on a moderate computer, the answer should easily be found within a minute. So if you use C#, Java, VB or whatever doesn't really matter. For the last of the three problems I mentioned in my first post, my Python code used 16.7 seconds. Some of the more "crazy" languages, like one called J, found the answer with the following code in 0.14 seconds:
numOfDiv=:[: */ 1: + [: +/"1 =@q:
{.(500 < numOfDiv&quot;0 t)#t=:+/\>: i.13000
But that's not really human readable code :blink:
Title: Project Euler
Post by: Aquilifer on July 01, 2008, 05:12:28 PM
Somewhat interesting, but the problems are not quite so difficult that I would start my compiler. I think the main problem comes from that the numbers are so big that it takes some time to solve it. So if you have a bad algorithm, 1 min limit might become tight.

The run time can be quite language and computer dependant. With more hardware you could cut the time down hugely. 1 min is so long that even distrbuted computing could be used. So where exactly is the runtime tested?

Does it have to be a true programming language? Problems not requiring so fast computing could be nicely solved by Matlab, Maple, etc.

EDIT: Ok the 1 min limit is not strict, but about 1 min max in a "modestly powered" computer. Didn't find comments about allowed languages, so I guess anything is allowed.
Title: Project Euler
Post by: T-Bag on July 01, 2008, 06:16:20 PM
Quote from: Carr0t;236233Most of the hardcore maths dudes I know code in either Fortran (ewww, stay away) or Python (which I equally don't like, but none of my languages of choice are good for quick maths processing).

For proper maths stuff (eg fitting graphs, solving equations, etc) I use Mathematica. It's pretty good, can do everything I can think of, and then a little more...but sometimes it's a little fussy and doesn't work for no reason (save & reload and it somehow starts working) which can be frustrating.
The visual basic is for the modeling side of my work which is where Mathematica isn't suitable, but I'm allowed to use whichever language I want (they just did a couple of modules on VB to get everyone to learn something simple).

Sounds like I should Learn C# then if it's a little like learning two languages at once. I might look into Java at a later data as I lived with 3 computer Scientists who should be able to help with any problems as they spent quite a bit of time with it.
Right all thats left now it to procrastinate
Title: Project Euler
Post by: Bob on July 01, 2008, 07:23:25 PM
Quote from: Aquilifer;236247EDIT: Ok the 1 min limit is not strict, but about 1 min max in a "modestly powered" computer. Didn't find comments about allowed languages, so I guess anything is allowed.
Yepp, that's correct. The 1 min. limit is more like a guideline. It is just so that if your program takes five minutes, it's a pointer that there's probably room for some improvements.

As for the language, there aren't any requirements at all. Some folks even use pen and paper for some tasks. And as for the problems - they aren't necessarily that difficult. The challenge lies in finding a good algorithmic approach, making they work on large numbers.

Or you could just google the answer - but that wouldn't be any fun :p

Quote from: T-Bag;236255For proper maths stuff (eg fitting graphs, solving equations, etc) I use Mathematica.
I have seen many folks using Mathematica on the problems - and they are fast!
Title: Project Euler
Post by: Aquilifer on July 01, 2008, 07:49:26 PM
Quote from: Bob;236262And as for the problems - they aren't necessarily that difficult. The challenge lies in finding a good algorithmic approach, making they work on large numbers.

Yep. Many of them are too 'mathematical' for me to interest (and in some I don't even know the terms), but some of them look worth to try. Actually this could be fun after looked the problems closer.

I solved one with Operation Flashpoint/ArmA script which was very fast (in ArmA). The good thing in that is if it doesn't work, you can shoot the frustration out :D