Page 1 of 5 12345 Last
  1. #1
    AceInfinity's Avatar
    Join Date
    Feb 2012
    Location
    Canada
    Posts
    1,722

    Project Euler

    Project Euler

    How many problems can you figure out? Let's have Sysnative compete as well for fun. (This thread will be the repository for any questions or answers provided by other members here.) I did this at my forum and we've figured out quite the number of them already. Through programmatically calculated results.

    It's actually pretty fun!

    Note: I challenge anyone to solve #406.

    If you'd like an idea on some of the results we came up with, or you're wondering how to get results. Here's a link that will be a starter location for you, to get your brain thinking in terms of these problems if you're struggling: Project Euler Answers Thread

    It was pretty popular on my own forum, so i'm going to share it here too. I want to see how active we can get this section of the forum. Even if you are not a programmer, I encourage you to try a few of the questions and solve them in whatever way you like. Otherwise... You can use Batch if you want lol, I don't care.

    Good luck to all participants :)

    ~Ace
    \n\n

    Automation Programmer
    Development Site: aceinfinity.net


    • Ad Bot

      advertising
      Beep.

        
       

  2. #2
    niemiro's Avatar
    Join Date
    Mar 2012
    Location
    District 12
    Posts
    7,852

    Re: Project Euler

    I'm pretty sure I completed problem 1, some time ago...

    I probably should do some more, but it is just a case of finding the time, and I have so many other projects going on at the moment.

    But maybe I can squeeze in the time for problem 2!

  3. #3
    AceInfinity's Avatar
    Join Date
    Feb 2012
    Location
    Canada
    Posts
    1,722

    Re: Project Euler

    Well, I was kinda hoping that more people would at least try, because this is really lame lol. Too lame.

    \n\n

    Automation Programmer
    Development Site: aceinfinity.net

  4. #4
    writhziden's Avatar
    Join Date
    May 2012
    Location
    Colorado
    Posts
    2,328
    • specs System Specs
      • Manufacturer:
        Sony
      • Model Number:
        VPCF232FX/B
      • Motherboard:
        Sony Corporation VAIO
      • CPU:
      • Memory:
        8.00 GB Crucial CT2KIT51264BF1339 DDR3 1333
      • Graphics:
      • Sound Card:
        Realtek High Definition Audio/nVidia High Definition Audio
      • Hard Drives:
        TOSHIBA MK5061GSY 500 GB (465 GB actual)
      • Case:
        Laptop black matte case with backlit keyboard
      • Cooling:
        Air cooling via fan and heat exchanger heatsink
      • Display:
        Laptop display
      • Operating System:
        Windows 7 Home Premium 64 Bit

    Re: Project Euler

    Sorry Ace. My time is really limited this week with a big deadline tomorrow for our program at my work. No time for fun stuff. ;-}

  5. #5
    AceInfinity's Avatar
    Join Date
    Feb 2012
    Location
    Canada
    Posts
    1,722

    Re: Project Euler

    I'm up to Problem 36 with a couple odd ones solved from later on. I'll share one of my solutions...

    Problem #28
    Starting with the number 1 and moving to the right in a clockwise direction a 5 by 5 spiral is formed as follows:



    It can be verified that the sum of the numbers on the diagonals is 101.

    What is the sum of the numbers on the diagonals in a 1001 by 1001 spiral formed in the same way?
    Answer #28
    Pretty happy with this solution, I was actually going to create the grid then loop over it, but looking at the structure and orientation of the numbers in that grid for the diagonals, I found a nice formula on my own :)

    Makes things much easier, and 100% faster lol.

    Code:
    //Answer #28: Project Euler
    static void Main(string[] args)
    {
    	int size = 5;
    	int sum = GetSpiralSum(size);
    	Console.WriteLine("Sum Of Diagonals ({0}x{0} Grid):\n\t= {1}", size, sum);
    	Console.ReadKey();
    }
    
    static int GetSpiralSum(int size)
    {
    	//formula for odd # grid size
    	int len = size + size - 1;
    	int sum = 0;
    	int index = 1;
    
    	sum = 1;
    	for (int i = 3; i <= size; i += 2, ++index)
    	{
    		for (int j = 0; j < 4; j++)
    		{
    			sum += (i * i) - ((j * i) - j);
    		}
    	}
    	return sum;
    }
    There's an even shorter way, but that is just a finer detail on the analysis that I did to come up with a result.
    Last edited by AceInfinity; 12-20-2012 at 03:50 AM.
    tom982 says thanks for this.
    \n\n

    Automation Programmer
    Development Site: aceinfinity.net

  6. #6
    AceInfinity's Avatar
    Join Date
    Feb 2012
    Location
    Canada
    Posts
    1,722

    Re: Project Euler

    There are some pretty difficult ones though...
    \n\n

    Automation Programmer
    Development Site: aceinfinity.net

  7. #7
    Will Watts's Avatar
    Join Date
    Mar 2012
    Location
    %tmp%
    Posts
    5,020
    • specs System Specs
      • Manufacturer:
        Alienware M15x
      • Model Number:
        M15x
      • CPU:
        i5 520 M @ 2.40GHz
      • Memory:
        8GB
      • Graphics:
        ATI Radeon HD 5800
      • Hard Drives:
        720GB 7200 rpm
      • Operating System:
        Windows 8 + Ubuntu

    Re: Project Euler

    I'm failing at question 1, so I'm not expecting to get too far...
    Has Sysnative Forums helped you? Please consider donating to help support the forum.


  8. #8
    AceInfinity's Avatar
    Join Date
    Feb 2012
    Location
    Canada
    Posts
    1,722

    Re: Project Euler

    Enumerate the numbers in that range, check for even divisibility by both 3 and 5, if both are multiples of that number, then keep track of that number. Maybe in an array or something. Then after you're done finding the numbers, add them together.

    In C# here was my solution for the first one:
    Code:
    Console.WriteLine(Enumerable.Range(1, 999).Where(i => i % 3 == 0 || i % 5 == 0).Sum());
    At least you are trying Everyone else just seems to read this thread and go silent lol
    \n\n

    Automation Programmer
    Development Site: aceinfinity.net

  9. #9
    niemiro's Avatar
    Join Date
    Mar 2012
    Location
    District 12
    Posts
    7,852

    Re: Project Euler

    Quote Originally Posted by AceInfinity View Post
    At least you are trying Everyone else just seems to read this thread and go silent lol
    You have spurred me into action. I have just completed problem 2
    AceInfinity says thanks for this.

  10. #10
    Will Watts's Avatar
    Join Date
    Mar 2012
    Location
    %tmp%
    Posts
    5,020
    • specs System Specs
      • Manufacturer:
        Alienware M15x
      • Model Number:
        M15x
      • CPU:
        i5 520 M @ 2.40GHz
      • Memory:
        8GB
      • Graphics:
        ATI Radeon HD 5800
      • Hard Drives:
        720GB 7200 rpm
      • Operating System:
        Windows 8 + Ubuntu

    Re: Project Euler

    I started in Python - haven't used it for a few months so I'm a bit rusty. I've since seen a much cleaner solution in Python - now that I've remembered bits of syntax. This was my first attempt though:

    Code:
    x = 0
    y = 0
    i = 0
    q = 0
    largest_x = 0
    largest_y = 0
    
    #multiples of 3
    while largest_x <= 1000:
        largest_x = 3*i
        if largest_x < 1000:
            x += largest_x
        i += 1
    
    
    #multiples of 5
    while largest_y <= 1000:
        largest_y = 5*q
        if largest_y < 1000:
            y += largest_y
        q += 1
    
    print (y+x)
    I couldn't remember much syntax, hence the overly complicated attempt. However, I'm still not sure why it doesn't work. If I change it to work out the example, under 10, it works fine. But I'm doing dodgy calculations and it goes wrong with higher numbers; maths isn't my strong point.
    AceInfinity says thanks for this.
    Has Sysnative Forums helped you? Please consider donating to help support the forum.


  11. #11
    AceInfinity's Avatar
    Join Date
    Feb 2012
    Location
    Canada
    Posts
    1,722

    Re: Project Euler

    Nice work guys :)

    No problem Will, you may struggle with a few, but otherwise some of these are fairly straightforward, and just require optimization for performance and speed of the calculations. I struggled with a couple so far, there's 2 that I can't solve at this point, some coin problem in 31, and 406. Not sure about the rest yet. I'm done 1-42, and I skipped 31. But other than that, 52, and 67 are completed on my account as well.

    It's good to see SOME activity here, even just the slightest bit... I'm happy :)

    My friend key on Project Euler:
    Code:
    75060110415387_a2341721eae9286d23fd272b7720e0a6

    ~Ace
    \n\n

    Automation Programmer
    Development Site: aceinfinity.net

  12. #12
    niemiro's Avatar
    Join Date
    Mar 2012
    Location
    District 12
    Posts
    7,852

    Re: Project Euler

    I have just had a look at 31. The problem for me is that although I can see a logical method for calculation, it would be a nightmare to debug even a tiny mistake.

  13. #13
    AceInfinity's Avatar
    Join Date
    Feb 2012
    Location
    Canada
    Posts
    1,722

    Re: Project Euler

    Quote Originally Posted by niemiro View Post
    I have just had a look at 31. The problem for me is that although I can see a logical method for calculation, it would be a nightmare to debug even a tiny mistake.
    ^ Behold, lol. That's my issue. I think I have figured out a way to do it though, although with modified permutations... The other admin on my forum wrote a recursive function in C++ to help achieve the result, although I'm not sure if he actually solved it yet. He just had a similar task for homework in his data class.
    \n\n

    Automation Programmer
    Development Site: aceinfinity.net

  14. #14
    Will Watts's Avatar
    Join Date
    Mar 2012
    Location
    %tmp%
    Posts
    5,020
    • specs System Specs
      • Manufacturer:
        Alienware M15x
      • Model Number:
        M15x
      • CPU:
        i5 520 M @ 2.40GHz
      • Memory:
        8GB
      • Graphics:
        ATI Radeon HD 5800
      • Hard Drives:
        720GB 7200 rpm
      • Operating System:
        Windows 8 + Ubuntu

    Re: Project Euler

    I'll soon move on to number 2.

    At least it's good for my maths.
    Has Sysnative Forums helped you? Please consider donating to help support the forum.


  15. #15
    AceInfinity's Avatar
    Join Date
    Feb 2012
    Location
    Canada
    Posts
    1,722

    Re: Project Euler

    Quote Originally Posted by Will Watts View Post
    I'll soon move on to number 2.

    At least it's good for my maths.
    There's some crazy ones in here that I can't solve because of my math as well. Specifically a couple physics ones that involve calculating the blast radius' volume in m^3 for a firecracker that explodes 100m above ground. :) I can calculate the range it would go (farthest), but the volume i'm clueless on.
    \n\n

    Automation Programmer
    Development Site: aceinfinity.net

  16. #16
    tom982's Avatar
    Join Date
    May 2012
    Location
    Southampton, England
    Age
    24
    Posts
    4,328
    • specs System Specs
      • Manufacturer:
        Custom
      • Model Number:
        Custom
      • Motherboard:
        ASUS P8Z77-V PRO
      • CPU:
        Intel Core i7 3770K @4.5GHz
      • Memory:
        Corsair Vengeance 2x4GB 1600MHz LP - White
      • Graphics:
        Gigabyte HD 7850 2GB @1050MHz
      • Sound Card:
        Stock
      • Hard Drives:
        Seagate Barracuda 2TB 7200rpm [Internal], 2x500GB Seagate FreeAgent (External)
      • Disk Drives:
      • Power Supply:
        Corsair TX650W V2 80+ Bronze
      • Case:
        NZXT Phantom 410 White
      • Cooling:
        Corsair H100 CPU Water Cooler, 1x140mm stock fan and 1x120mm stock fan
      • Display:
        LG 23&quot; IPS Monitor (1920*1080)
      • Operating System:
        Windows 10

    Re: Project Euler

    Which problem is it Ace?

    Scrap that, 317.

  17. #17
    niemiro's Avatar
    Join Date
    Mar 2012
    Location
    District 12
    Posts
    7,852

    Re: Project Euler

    Quote Originally Posted by tom982 View Post
    Which problem is it Ace?

    Scrap that, 317.
    Well, I already know that any problem with a number that high is out of my league

  18. #18
    AceInfinity's Avatar
    Join Date
    Feb 2012
    Location
    Canada
    Posts
    1,722

    Re: Project Euler

    I'll post what I shared to others. This is all I did for that challenge, but I never proceeded to advance any farther than this on 317.



    Calculating the largest arc, comes with background knowledge that the pieces being thrown away from the center point at a 45 degree angle will go the farthest (assuming no other external forces in this problem, as mentioned).

    This means that the pieces from the firecracker, when it explodes 100m above ground, that are going in a 45 degree angle from that horizontal plane 100m above ground, will go the farthest horizontally. So we would be able to calculate the distance it goes horizontally by taking the horizontal component of the initial velocity, and plugging it into a formula to calculate the range of this projectile motion. (Note: At the point where it falls to the same plane; 100m above ground away from the original point... It moves even farther because of momentum and inertia while it's falling to the ground the rest of that 100m).

    Aside from that, I am not too sure on how you would calculate the volume (all directions, not just left and right on a 2D representation,) for this explosion zone formed when it goes off. It would be more like a dome, so i'm sure there's some formula out there as well for this, which involves gravity, the displacement from the center, and the height).

    But, there's also the area above that 45 degree blast arc, along with the point directly above the firecracker, and perpendicular to the ground.
    I took Physics, but that knowledge is forgotten now. I can only remember bits and pieces.
    \n\n

    Automation Programmer
    Development Site: aceinfinity.net

  19. #19
    tom982's Avatar
    Join Date
    May 2012
    Location
    Southampton, England
    Age
    24
    Posts
    4,328
    • specs System Specs
      • Manufacturer:
        Custom
      • Model Number:
        Custom
      • Motherboard:
        ASUS P8Z77-V PRO
      • CPU:
        Intel Core i7 3770K @4.5GHz
      • Memory:
        Corsair Vengeance 2x4GB 1600MHz LP - White
      • Graphics:
        Gigabyte HD 7850 2GB @1050MHz
      • Sound Card:
        Stock
      • Hard Drives:
        Seagate Barracuda 2TB 7200rpm [Internal], 2x500GB Seagate FreeAgent (External)
      • Disk Drives:
      • Power Supply:
        Corsair TX650W V2 80+ Bronze
      • Case:
        NZXT Phantom 410 White
      • Cooling:
        Corsair H100 CPU Water Cooler, 1x140mm stock fan and 1x120mm stock fan
      • Display:
        LG 23&quot; IPS Monitor (1920*1080)
      • Operating System:
        Windows 10

    Re: Project Euler

    If I've worked it out correctly, then the X directly to the right of the point of explosion on your diagram is 40.77471948m away, and the X where the fragments would touch the floor is 87.41807227m away from your centre line. I don't know if it helps though, as the path of the projectile is curved so the volume can't be calculated with any simple calculations, it's going to be some hideously complicated differential equation followed by a lovely bit of integration, and the bottom party is the easy bit

    I'll ask my differential equations lecturer about this when I go back to uni, there's got to be an equation to use for this :)

  20. #20
    Laxer's Avatar
    Join Date
    Feb 2012
    Location
    Portland, OR
    Posts
    3,850
    • specs System Specs
      • Motherboard:
        GIGABYTE GA-Z97MX
      • CPU:
        Intel 4690K @ 4.6Ghz
      • Memory:
        Corsair Vengeance Pro 16GB @ 2666Mhz
      • Graphics:
        2x Sapphire 7970s
      • Hard Drives:
        2x Corsair Force 3GT 120GB (RAID 0) + 2x Western Digital Red 3TB (RAID 1)
      • Disk Drives:
        LG Black 10X Blu-ray Burner
      • Power Supply:
        CORSAIR 950HX
      • Case:
        Corsair 350D
      • Cooling:
        Corsair H100i
      • Display:
        3 x 22&quot; Samsung 1080p Displays
      • Operating System:
        Windows 8 Pro x64

    Re: Project Euler

    It begs the question to use the Euler method with a really small step size... Imagine that

Page 1 of 5 12345 Last

Similar Threads

  1. [Project] StringCrypt - Work in Progress
    By AceInfinity in forum Programming
    Replies: 1
    Last Post: 10-01-2012, 11:38 PM
  2. Project Ideas
    By HonorGamer in forum Programming
    Replies: 15
    Last Post: 07-29-2012, 05:08 PM
  3. VB Project... To help me learn
    By GZ in forum Programming
    Replies: 7
    Last Post: 06-02-2012, 10:57 PM

Log in

Log in