
12182012, 11:56 PM #1
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 :)
~AceAutomation Programmer
Microsoft MVP [2012  2018]

Ad Bot
 Beep.

12192012, 06:00 AM #2
Windows Update Expert
Developer
 Join Date
 Mar 2012
 Location
 District 12
 Posts
 7,993
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!

12192012, 11:01 PM #3
Re: Project Euler
Well, I was kinda hoping that more people would at least try, because this is really lame lol. Too lame.
Automation Programmer
Microsoft MVP [2012  2018]

12202012, 12:03 AM #4
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. ;}

12202012, 03:46 AM #5
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?
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; }
Last edited by AceInfinity; 12202012 at 03:50 AM.
Automation Programmer
Microsoft MVP [2012  2018]

12202012, 03:52 AM #6
Re: Project Euler
There are some pretty difficult ones though...
Automation Programmer
Microsoft MVP [2012  2018]

12212012, 12:30 PM #7

12212012, 11:38 PM #8
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());
Automation Programmer
Microsoft MVP [2012  2018]

12222012, 04:07 AM #9

12222012, 10:10 AM #10
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)

12222012, 07:11 PM #11
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 142, 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
~AceAutomation Programmer
Microsoft MVP [2012  2018]

12232012, 04:11 AM #12
Windows Update Expert
Developer
 Join Date
 Mar 2012
 Location
 District 12
 Posts
 7,993
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.

12232012, 08:37 PM #13
Re: Project Euler
^ 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.
Automation Programmer
Microsoft MVP [2012  2018]

12242012, 08:56 AM #14

12242012, 07:48 PM #15
Re: Project Euler
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.
Automation Programmer
Microsoft MVP [2012  2018]

12282012, 09:58 AM #16
Re: Project Euler
Which problem is it Ace?
Scrap that, 317.

12282012, 10:05 AM #17

12292012, 07:59 AM #18
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.Automation Programmer
Microsoft MVP [2012  2018]

12292012, 08:01 PM #19
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 :)

12292012, 10:14 PM #20
Re: Project Euler
It begs the question to use the Euler method with a really small step size... Imagine that
Similar Threads

[Project] StringCrypt  Work in Progress
By AceInfinity in forum ProgrammingReplies: 1Last Post: 10012012, 11:38 PM 
Project Ideas
By HonorGamer in forum ProgrammingReplies: 15Last Post: 07292012, 05:08 PM 
VB Project... To help me learn
By GZ in forum ProgrammingReplies: 7Last Post: 06022012, 10:57 PM