Fires of Heaven Guild Message Board  

Go Back   Fires of Heaven Guild Message Board > General forums > Development
User Name
Password
Or, use your gamerDNA username: (more...)
ForumSpy Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
Old 09-26-2008, 03:09 AM   #1 (permalink)
Grooverider
1234567890
 
Grooverider's Avatar
 
Join Date: Aug 2002
Location: Svenborgia
Posts: 1,299
Project Euler

I've been working through Project Euler Project Euler. Anyone done this before? I'm having a great time.

Basically 200 problems to be solved using programming, using any language you like. I started today; up to problem 5.

Here's my solution in C# for number 5.
Code:
 public class problem5
    // 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.
    // What is the smallest number that is evenly divisible by all of the numbers from 1 to 20?
    {
        public void ProblemFive(){
            for (int i = 40; i != 1000000000; i++){
                bool divides = checkNumber(i);
                if (divides == true){
                    Console.WriteLine("Found it: {0}", i);
                    break;
                }            
            }   
        }

        static bool checkNumber(int number){
            int i = 11;
            while (i != 20){
                if (number % i != 0)  
                    return false;    
                i++;
            }
            return true;                
        }

Last edited by Grooverider; 09-26-2008 at 03:12 AM.. Reason: Adding code brackets.
Grooverider is online now   Reply With Quote
Old 09-26-2008, 08:10 AM   #2 (permalink)
Vinen
Open the eyes
 
Vinen's Avatar
 
Join Date: Oct 2002
Location: Not in fucking Acton, MA anymore!
Posts: 4,260
Neat, wish they were ordered somehow by difficulty! Going to try my hand at a few of the newer ones.

202 looks like fun... ;d

Last edited by Vinen; 09-26-2008 at 08:12 AM..
Vinen is online now   Reply With Quote
Old 09-26-2008, 11:03 AM   #3 (permalink)
Grooverider
1234567890
 
Grooverider's Avatar
 
Join Date: Aug 2002
Location: Svenborgia
Posts: 1,299
I've done up to 11 now, working through them..
Grooverider is online now   Reply With Quote
Old 09-28-2008, 09:34 AM   #4 (permalink)
Candiarie
Registered User
 
Candiarie's Avatar
 
Join Date: Jan 2003
Posts: 978
+0 Internets
I do them in my programming class to keep myself awake. Looking at other people's solutions will usually make me feel like a tool when I see how much smarter they are. I learned about Python generators though. That shit is pretty cool.
__________________
Candiarie is offline   Reply With Quote
Old 09-28-2008, 09:36 AM   #5 (permalink)
Candiarie
Registered User
 
Candiarie's Avatar
 
Join Date: Jan 2003
Posts: 978
+0 Internets
Quote:
Originally Posted by Vinen View Post
202 looks like fun... ;d
Hahahahaha.


201 isn't that bad though
__________________

Last edited by Candiarie; 09-28-2008 at 09:44 AM..
Candiarie is offline   Reply With Quote
Old 09-28-2008, 01:07 PM   #6 (permalink)
Grooverider
1234567890
 
Grooverider's Avatar
 
Join Date: Aug 2002
Location: Svenborgia
Posts: 1,299
Well doing it in C# isn't really ideal. Once I get high enough, 100+, i'm going to switch to a functional language - maybe Haskell or F#.

The python optimized code i've seen so far for the answers has been really really beautiful.
Grooverider is online now   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On

uberguilds network



All times are GMT -7. The time now is 11:12 AM.


Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.0.0 RC6