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

    Re: Project Euler

    Quote Originally Posted by tom982 View Post
    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 :)
    Yeah, I just don't know what the equation would be to calculate that kind of volume, If you did though, you would have to probably end up adding the volume from where it hits the 100m mark for any pieces that fly with an initial velocity helping the fragments move higher from that point after the blast, and then You would have to probably add the Cylinder's volume that gets created from the point where it falls down from the farthest reach at 100m above ground. But for momentum that carries pieces farther than that displacement the last 100m.... I honestly don't know.

    I'm assuming that you would need to find the velocity in the horizontal vector for any pieces that keep moving away from the centerpoint of the blast for the last 100m of the fall. Which would be Vmax, and I can get all that, but I don't know anything for volume. I know 2D, not 3D.

    Here's my belief though. In theory, i'd assume this is how you would end up getting the result though:


    (Image brought to you by Photoshop )

    Quote Originally Posted by Laxer View Post
    It begs the question to use the Euler method with a really small step size... Imagine that
    I will pass... lol I'm a programmer not a rocket scientist.

    These were fun while I didn't require a mathematician to solve them anyways :)
    Last edited by AceInfinity; 12-30-2012 at 03:18 AM.
    \n\n

    Automation Programmer
    Development Site: aceinfinity.net


    • Ad Bot

      advertising
      Beep.

        
       

  2. #22
    Laxer's Avatar
    Join Date
    Feb 2012
    Location
    Portland, OR
    Posts
    3,841
    • 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" Samsung 1080p Displays
      • Operating System:
        Windows 8 Pro x64

    Re: Project Euler

    You were the one who introduced differential calculus into the equation

    I was just giving an easy way to integrate without taking the derivative by finding the area under the curve in steps...
    On a mathematical note... The path of the projectiles will be parabolic(you're image shows a semi-circle although you probably already knew this)

    if you let the point where the firecracker exploads be the value x=0 and be y=100(m) you will have the path split in half by the y-axis, you could then treat this as a rotated solid around the y axis and solve for the volume...

    Been >4 years since I have gone down this road... so might be wise finding someone with more recent math knowledge.

    There are many methods to do this, I always preferred shells over disks but this should give you the basic idea



    With the example above you could just do the integral from 0 -> x-range instead of going -x-range->x-range and removing the extra...
    If you would like I can probably solve it, however I wouldn't touch any programming languages and just do it on paper...



    Was thinking about this and the answer above is only partially right, I left out a critical are of the volume... Anything were the projectiles would be launched between 0 and 180 degs (up) wouldn't be covered... You would have to through in variable into it thus making it more of a programming question

    Latest thought on the approach... Treat everything firstly as if they are launched parallel or lower to the ground thus the volume would be just one parabola rotated around the y axis...

    Then take this a tweak the equation to allow different launch angles for anything greater than 0 and less than 180 (0-pi in rad) and throw this into the computer remembering to subtract the first equation so we don't count it a million times...

    I'm on winter break I don't want to think anymore
    Last edited by Laxer; 12-30-2012 at 06:31 AM.

  3. #23
    tom982's Avatar
    Join Date
    May 2012
    Location
    Southampton, England
    Age
    23
    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" IPS Monitor (1920*1080)
      • Operating System:
        Windows 10

    Re: Project Euler

    lol, I think I'll pass on that one!

  4. #24
    Laxer's Avatar
    Join Date
    Feb 2012
    Location
    Portland, OR
    Posts
    3,841
    • 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" Samsung 1080p Displays
      • Operating System:
        Windows 8 Pro x64

    Re: Project Euler

    If you think about it aces image above is really only a fraction of the answer because they projectiles could be launched say straight up or...

    I think the final shape will be somewhat conical but I am not sure

  5. #25
    tom982's Avatar
    Join Date
    May 2012
    Location
    Southampton, England
    Age
    23
    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" IPS Monitor (1920*1080)
      • Operating System:
        Windows 10

    Re: Project Euler

    Oops, I replied to the post on the end of page 1 thinking it was the end of the thread, only to find my post isn't in context any more.

    Will it be a semi circle at the top though? That's the bit I can't get my head around, I just can't imagine it being that simple for the upper half.

  6. #26
    Laxer's Avatar
    Join Date
    Feb 2012
    Location
    Portland, OR
    Posts
    3,841
    • 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" Samsung 1080p Displays
      • Operating System:
        Windows 8 Pro x64

    Re: Project Euler

    I think it would be a point... If you treat everything as a particle launched from the same point the particle that reaches the highest point would have been fired straight up (90 deg) anything fired at a different angle would have an x component and a y component less than the max height... I can't think of the exact shape but it would flared out at the bottom and pointed towards the top...

    Bugs me now that I cant remember the math to back it up >.<

  7. #27
    tom982's Avatar
    Join Date
    May 2012
    Location
    Southampton, England
    Age
    23
    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

    I'm curious now, and it'll bug me until I find out what it's like. I've got Maple 16 at my uni flat, but not with me at the moment so I'm going to have to plot this line by line until a shape emerges!

    y=xtan(θ)-(9.81x^2(1+tan^2(θ)))/800

  8. #28
    Laxer's Avatar
    Join Date
    Feb 2012
    Location
    Portland, OR
    Posts
    3,841
    • 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

    Perhaps it will still be parabolic...

    something similar to this but rotated:



    sorry for giving you all this extra thought process Tom
    tom982 says thanks for this.

  9. #29
    tom982's Avatar
    Join Date
    May 2012
    Location
    Southampton, England
    Age
    23
    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

    Nice job with the graph! It looks great - what did you use to make it?

    Are those numbers specific to this problem, or is it just a general idea of the shape for projectiles?

  10. #30
    Laxer's Avatar
    Join Date
    Feb 2012
    Location
    Portland, OR
    Posts
    3,841
    • 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

    Just a general idea of a projectile launched with a fixed velocity...

    I know there is an app at wolframalpha to solve optimal angle that shows the outside curve well but I wasn't able to find it

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

    Re: Project Euler

    Quote Originally Posted by Laxer View Post
    If you think about it aces image above is really only a fraction of the answer because they projectiles could be launched say straight up or...

    I think the final shape will be somewhat conical but I am not sure
    Half?! lol... Look at where that horizontal 100m line is in my drawing, below the top of the semi-circle. I accounted for pieces that fly anywhere above 0 or 180 degrees (depending on how you look at it), but it would be a semi-circle. Take this illustration for example:



    Now imagine if I was to draw a line (affected by gravity) for every fraction of a degree in that drawing... Pieces just a fraction of a degree off from 90 degrees, would go just slightly lower than the piece going straight up, because part of the vertical component with it's momentum split into an x and y component is taken away (because part of the energy from the blast propelling that chunk, is being put to make it move to the side, instead of all straight up). Agree?

    Thus, It would be a point at the top, but you would hardly be able to tell.

    There's just a fraction of the velocity missing for the y component when it's not going directly 90 degrees, and that would affect it's height slightly. Think about it in terms of x and y components. At a 45 degree angle, there's an equal x and y component for velocity, and the acceleration of gravity just so happens to make it result in a curve once it overcomes the force of the blast pushing up against the flow of gravity.
    Last edited by AceInfinity; 12-31-2012 at 06:47 AM.
    \n\n

    Automation Programmer
    Development Site: aceinfinity.net

  12. #32
    tom982's Avatar
    Join Date
    May 2012
    Location
    Southampton, England
    Age
    23
    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

    Loving the scientific model Ace

    I have to disagree though, I don't think it is a semi circle. Just to clarify, I'm talking about the bit above point of explosion, ie the upper half.

    It doesn't need saying that the maximum height reached will be the fragment fired at 90o from the horizontal. To calculate the distance, I rearranged one of the SUVAT equations:

    V2 = U2 + 2AS

    To give:

    S = (V2 - U2)/2A

    Inputting our data, we get:

    S = (02 - 202)/2*-9.81
    S = 20.38735984m

    I also did it with V=U+AT and S=UT+0.5AT2 and got the same result.

    Now, calculating how wide the blast radius is:

    These are the y-components of the projectile:

    V=U+AT => 0=20sin(45)-9.8t => t=1.441604039s

    (I worked it out the long way, calculating time first, because I thought it would be useful to know time for other calculations)

    Then with the x-components:

    s=20cos(45)t (from S=UT+0.5AT2 , A=0 as it's the x-component so S=UT)
    s=20.38735984m

    But this is only to the point where the projectile is at its max height, ie in the middle, so we double it to get:

    40.77471968m

    If it was a semi circle, then the radius would be the same all around the origin :)

    Tom
    Last edited by tom982; 12-31-2012 at 08:51 AM.

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

    Re: Project Euler

    Quote Originally Posted by tom982 View Post
    Loving the scientific model Ace

    I have to disagree though, I don't think it is a semi circle. Just to clarify, I'm talking about the bit above point of explosion, ie the upper half.

    It doesn't need saying that the maximum height reached will be the fragment fired at 90o from the horizontal. To calculate the distance, I rearranged one of the SUVAT equations:

    V2 = U2 + 2AS

    To give:

    S = (V2 - U2)/2A

    Inputting our data, we get:

    S = (02 - 202)/2*-9.81
    S = 20.38735984m

    I also did it with V=U+AT and S=UT+0.5AT2 and got the same result.

    Now, calculating how wide the blast radius is:

    These are the y-components of the projectile:

    V=U+AT => 0=20sin(45)-9.8t => t=1.441604039s

    (I worked it out the long way, calculating time first, because I thought it would be useful to know time for other calculations)

    Then with the x-components:

    s=20cos(45)t (from S=UT+0.5AT2 , A=0 as it's the x-component so S=UT)
    s=20.38735984m

    But this is only to the point where the projectile is at its max height, ie in the middle, so we double it to get:

    40.77471968m

    If it was a semi circle, then the radius would be the same all around the origin :)

    Tom
    No, not the origin but the base (as reference to where the pieces land being the widest part of the semi-circle. Because pieces flying off at 45 degrees, above the 100m plane, will go the farthest by the time they hit the ground. So really, the only relevant chunks that make up the outer "shell" of the volume, would be the pieces that fly off from 45 degrees above the 100m plane, and up to the 90 degree angle. Gravity will take care of the rest.

    You've also got to remember, that the origin you are talking about is not positioned at the core of a half of a sphere as what this blast radius would look like. It's about somewhere in the half of a half of a sphere range.

    edit: maybe not exactly half of a half, because it depends on how high the chunks fly from the point of explosion relative to the distance from the point of explosion to the ground.

    Last edited by AceInfinity; 12-31-2012 at 09:00 AM.
    \n\n

    Automation Programmer
    Development Site: aceinfinity.net

  14. #34
    Redeye3323's Avatar
    Join Date
    Jan 2013
    Location
    Norfolk, East Anglia, England, United Kingdom, Europe, Earth, Milky Way, Universe
    Age
    24
    Posts
    7
    • specs System Specs
      • Motherboard:
        Asus P7P55D Pro Intel P55 LGA1156
      • CPU:
        Inter Core i5 750 @2.66GHz
      • Memory:
        2x 2GB DDR3 RAM
      • Graphics:
        Radeon HD5770 Dedicated GPU
      • Sound Card:
        In-Built
      • Hard Drives:
        1TB Western Digital Caviar Black
      • Disk Drives:
        LG All-in-one
      • Power Supply:
        Corsair HX650
      • Case:
        Antec 900
      • Cooling:
        Case Fans &amp; Internal Fans
      • Display:
        Samsung SyncMaster SA350 (LED - 1080p)
      • Operating System:
        Windows 7 Professional 64-bit :)

    Re: Project Euler

    Hey all,

    I went for a complex c# method for doing Problem 1 but it doesn't work, can anyone spot the problem :S

    Code:
    int counter = 0;
                int x = 3;
                int[] multiplesOfThree = new int[333];
                int y = 5;
                int[] multiplesOfFive = new int[199];
                int result = 0;
    
                while (x < 1000)
                {
                    multiplesOfThree[counter] = x;
                    counter++;
                    x = x + 3;
                }
    
                counter = 0;
    
                while (y < 1000)
                {
                    multiplesOfFive[counter] = y;
                    counter++;
                    y = y + 5;
                }
    
                foreach (int i in multiplesOfThree)
                {
                    result = result + i;
                }
    
                foreach (int i in multiplesOfFive)
                {
                    result = result + i;
                }
    
                Console.WriteLine("Result = " + result);
    
                Console.ReadLine();

    Tech Enthusiast

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

    Re: Project Euler

    Quote Originally Posted by Redeye3323 View Post
    Hey all,

    I went for a complex c# method for doing Problem 1 but it doesn't work, can anyone spot the problem :S

    Code:
    int counter = 0;
                int x = 3;
                int[] multiplesOfThree = new int[333];
                int y = 5;
                int[] multiplesOfFive = new int[199];
                int result = 0;
    
                while (x < 1000)
                {
                    multiplesOfThree[counter] = x;
                    counter++;
                    x = x + 3;
                }
    
                counter = 0;
    
                while (y < 1000)
                {
                    multiplesOfFive[counter] = y;
                    counter++;
                    y = y + 5;
                }
    
                foreach (int i in multiplesOfThree)
                {
                    result = result + i;
                }
    
                foreach (int i in multiplesOfFive)
                {
                    result = result + i;
                }
    
                Console.WriteLine("Result = " + result);
    
                Console.ReadLine();
    May be good in theory, but recognize, that you would be adding duplicates. Calculating multiples of 3, and 5 separately, then adding the values to the result, you would be adding 15 twice for example. Once for iterating through the multiples of 3, and once again for iterating through the multiples of 5... Since, 15 is evenly divisible, by both 3 and 5. :)

    Doing it separately you'd have to check if the value already exists in the array, if you're deciding to use an array for this:
    Code:
    int[] arr = new int[1000 / 5 + 1000 / 3];
    int count = 0;
    int result = 0;
    
    for (int i = 3; i < 1000; i += 3)
    {
    	if (Array.IndexOf(arr, i) < 0)
    	{
    		arr[count++] = i;
    	}
    }
    
    for (int i = 5; i < 1000; i += 5)
    {
    	if (Array.IndexOf(arr, i) < 0)
    	{
    		arr[count++] = i;
    	}
    }
    
    for (int i = 0; i < count; i++)
    {
    	result += arr[i];
    }
    Otherwise, you can just loop from 3 to 999 once and check for even divisibility using the modulus operator:
    Code:
    int result = 0;
    for (int i = 3; i < 1000; i++)
    {
    	if (i % 3 == 0 || i % 5 == 0)
    	{
    		result += i;
    	}
    }
    Console.WriteLine(result);
    Otherwise you can use LINQ to do relatively the same thing. Although I would've just used the loop:
    Code:
    Enumerable.Range(3, 997).Where(i => i % 3 == 0 || i % 5 == 0).Sum();
    If you want to review an answer, I've posted up to ~45 answers in C# on the net.
    Last edited by AceInfinity; 01-21-2013 at 10:45 PM.
    \n\n

    Automation Programmer
    Development Site: aceinfinity.net

  16. #36
    Will Watts's Avatar
    Join Date
    Mar 2012
    Location
    %tmp%
    Posts
    5,000
    • 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

    Adding duplicates must have been where I went wrong as well. Time to give this another shot.
    Has Sysnative Forums helped you? Please consider donating to help support the forum.


  17. #37
    Redeye3323's Avatar
    Join Date
    Jan 2013
    Location
    Norfolk, East Anglia, England, United Kingdom, Europe, Earth, Milky Way, Universe
    Age
    24
    Posts
    7
    • specs System Specs
      • Motherboard:
        Asus P7P55D Pro Intel P55 LGA1156
      • CPU:
        Inter Core i5 750 @2.66GHz
      • Memory:
        2x 2GB DDR3 RAM
      • Graphics:
        Radeon HD5770 Dedicated GPU
      • Sound Card:
        In-Built
      • Hard Drives:
        1TB Western Digital Caviar Black
      • Disk Drives:
        LG All-in-one
      • Power Supply:
        Corsair HX650
      • Case:
        Antec 900
      • Cooling:
        Case Fans &amp; Internal Fans
      • Display:
        Samsung SyncMaster SA350 (LED - 1080p)
      • Operating System:
        Windows 7 Professional 64-bit :)

    Re: Project Euler

    I spent an hour debugging that whole program, and it seems that my understanding of the problem itself was the actual issue. Visual Studio doesn't have any way of debugging my brain does it :laugh:

    I don't know how to use Enumerables if I am honest :S

    [UPDATE] I went back and made a simple change to my code which fixed my issue.

    I changed

    Code:
    foreach (int i in multiplesOfFive)
    {
        result = result + i;
    }
    to

    Code:
    foreach (int i in multiplesOfFive)
    {
        if ((i % 3) != 0)
        {
              result = result + i;
        }
    }

    Tech Enthusiast

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

    Re: Project Euler

    My last method there was an IEnumerable result that I applied LINQ to, in order to get a result of the summed values. :)
    \n\n

    Automation Programmer
    Development Site: aceinfinity.net

  19. #39
    AceInfinity's Avatar
    Join Date
    Feb 2012
    Location
    Canada
    Posts
    1,716

    Re: Project Euler

    Problem #55 Solution
    Code:
    bool isPalindrome(std::string s, int lowerIndex, int upperIndex)
    {
    	if (upperIndex <= lowerIndex) return true;
    	if (s[lowerIndex] != s[upperIndex]) return false;
    	return isPalindrome(s, ++lowerIndex, --upperIndex);
    }
    
    void Problem55()
    {
    	// How many Lychrel numbers are there below ten-thousand?
    	int count = 0;
    	for (int i = 1; i < 10000; i++)
    	{
    		int steps = 0;
    		unsigned long long j = i, k;
    		bool isLychrel = false;
    		while (!isLychrel && steps < 50)
    		{
    			std::stringstream ss;
    			std::string s; ss << j; s = ss.str();
    			std::reverse(s.begin(), s.end());
    
    			ss.str(s); ss >> k;
    
    			// Empty and clear string stream
    			ss.str(std::string()); // Set string contents
    			ss.clear(); // Clear EOF flag bit
    
    			ss << j + k; s = ss.str(); // Sum
    			if (isPalindrome(s, 0, s.length() - 1)) isLychrel = true;
    
    			ss >> j;
    			steps++;
    		}
    		if (!isLychrel) count++;
    	}
    	std::cout << "Ans: " << count << std::endl;
    }
    I wrote this one in C++ a while ago.
    \n\n

    Automation Programmer
    Development Site: aceinfinity.net

  20. #40
    AceInfinity's Avatar
    Join Date
    Feb 2012
    Location
    Canada
    Posts
    1,716

    Re: Project Euler

    Lets (re?)awaken the programmers here. :) I'm having issues with #60. I've wrote it out a few times, but it seems a straight bruteforce iterative method isn't going to work. Even with generated primes and iterators pulling primes out to concatenate. My concatenation methods are vamped up for optimization as well, no strings, just straight math to avoid casting back and forth, but I still haven't got a solution (within a reasonable amount of time).
    \n\n

    Automation Programmer
    Development Site: aceinfinity.net

Page 2 of 5 First 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