
12302012, 03:01 AM #21
Re: Project Euler
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 )
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; 12302012 at 03:18 AM.
Automation Programmer
Microsoft MVP [2012  2018]

Ad Bot
 Beep.

12302012, 06:06 AM #22
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 semicircle 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 yaxis, 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 > xrange instead of going xrange>xrange 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 (0pi 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 anymoreLast edited by Laxer; 12302012 at 06:31 AM.

12302012, 06:39 AM #23
Re: Project Euler
lol, I think I'll pass on that one!

12302012, 07:12 AM #24
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

12302012, 07:39 AM #25
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.

12302012, 06:37 PM #26
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 >.<

12302012, 07:43 PM #27
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

12302012, 07:59 PM #28
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

12302012, 08:12 PM #29
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?

12302012, 11:31 PM #30
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

12312012, 06:44 AM #31
Re: Project Euler
Half?! lol... Look at where that horizontal 100m line is in my drawing, below the top of the semicircle. I accounted for pieces that fly anywhere above 0 or 180 degrees (depending on how you look at it), but it would be a semicircle. 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; 12312012 at 06:47 AM.
Automation Programmer
Microsoft MVP [2012  2018]

12312012, 08:37 AM #32
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 90^{o} from the horizontal. To calculate the distance, I rearranged one of the SUVAT equations:
V^{2} = U^{2} + 2AS
To give:
S = (V^{2}  U^{2})/2A
Inputting our data, we get:
S = (0^{2}  20^{2})/2*9.81
S = 20.38735984m
I also did it with V=U+AT and S=UT+0.5AT^{2} and got the same result.
Now, calculating how wide the blast radius is:
These are the ycomponents 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 xcomponents:
s=20cos(45)t (from S=UT+0.5AT^{2} , A=0 as it's the xcomponent 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 :)
TomLast edited by tom982; 12312012 at 08:51 AM.

12312012, 08:55 AM #33
Re: Project Euler
No, not the origin but the base (as reference to where the pieces land being the widest part of the semicircle. 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; 12312012 at 09:00 AM.
Automation Programmer
Microsoft MVP [2012  2018]

01212013, 06:19 PM #34
 Join Date
 Jan 2013
 Location
 Norfolk, East Anglia, England, United Kingdom, Europe, Earth, Milky Way, Universe
 Age
 25
 Posts
 7
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 ◉

01212013, 10:37 PM #35
Re: Project Euler
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]; }
Code:int result = 0; for (int i = 3; i < 1000; i++) { if (i % 3 == 0  i % 5 == 0) { result += i; } } Console.WriteLine(result);
Code:Enumerable.Range(3, 997).Where(i => i % 3 == 0  i % 5 == 0).Sum();
Last edited by AceInfinity; 01212013 at 10:45 PM.
Automation Programmer
Microsoft MVP [2012  2018]

01222013, 07:07 AM #36

01222013, 05:09 PM #37
 Join Date
 Jan 2013
 Location
 Norfolk, East Anglia, England, United Kingdom, Europe, Earth, Milky Way, Universe
 Age
 25
 Posts
 7
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; }
Code:foreach (int i in multiplesOfFive) { if ((i % 3) != 0) { result = result + i; } }
◉ Tech Enthusiast ◉

01222013, 11:37 PM #38
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. :)
Automation Programmer
Microsoft MVP [2012  2018]

06022013, 06:45 PM #39
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 tenthousand? 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; }
Automation Programmer
Microsoft MVP [2012  2018]

06082013, 02:02 PM #40
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).
Automation Programmer
Microsoft MVP [2012  2018]
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