I’m sorry to use (or imply) such strong language, but I’m honestly at a loss. I’m guessing the creator of this challenge is a physics enthusiast. I don’t understand the question or the Wikipedia article, both of which I’ve read multiple times. I am smart enough to look for a formula to use, and there are two formulas in the Wikipedia article that we can use to determine the orbital period, but we don’t have all the required bits of information to use the formula.
We are provided with the average altitude as an argument to the function and we are also provided with the radius and GM value of the Earth.
- We aren’t provided with the orbit’s semi-major axis in meters.
- We aren’t provided with the mean density (of the Earth?).
So, I feel my frustration is justified.
I know that there’s an answer in the Wiki and I also noticed that there’s a video to watch somewhere else here in the forum, I also suspect that a person with some understanding of physics could glean the necessary information from the combination of the challenge description and the Wikipedia article.
What’s going on here? This doesn’t look like a programming challenge, but a physics challenge. If it’s a matter of implementing a formula, why don’t they provide the formula and identify the parts of it?
A challenge which is literally impossible for me to solve without looking at the solution ahead of time isn’t a useful educational device or an effective testing device.
Please, someone tell me that I’ve missed some important detail that makes this possible without simply copying and pasting the solution.
Hi, I agree that it would be better to give the formula in the challenge itself. Anyway the formula is
T = 2*pi*sqrt(r^3/GM) where
r = earthRadius+avgAlt, which is the distance from midpoint of the earth to the object, and
T = Orbital Period
Thank you very much. I’m most concerned about that r. I read the same formula in the wiki, but it didn’t provide an explanation there, either. I want to know how you arrived at the definition of r.
We get the radius of the Earth in the question and the average altitude is one of values in the array that’s passed to the function as an argument, but how did you know to put them together?
I’m finally getting that an axis is a distance. For some reason, I was thinking that it was related to a direction in some way.
I think I have enough information to finish the challenge now and I really appreciate that. I hope to never see another question like this again.
r is the distance between the two objects (“r is the orbit’s semi-major axis in meters”). Since gravity works on the middle of the objects (and because the radius of the earth is given…), you have to add the radius to the average altitude.
I don’t recall any
For some reason, I seem to always have the most difficulty with the things that everyone else finds to be the easiest.
The thing that helped me to understand the best was this line from BenGitter:
Since gravity works on the middle of the objects (and because the radius of the earth is given…), you have to add the radius to the average altitude.
In retrospect, I think I may have overreacted a little bit. The Wikipedia article still makes no sense to me and neither did that video from the other thread, but I can understand adding the radius of the earth to the altitude of the satellite to get the distance.
I would like to second your frustration. I actually think a lot of the challenges are needlessly nerdy, in the sense that understanding the question / problem is way more difficult than the actual coding that is necessary to solve it. Nothing wrong with nerdy in itself of course but in this case it is very counter-productive.
I know this is from last year but I was thinking the same thing!
I went to the WIKI and the formula was not the same. It just drove me crazy. I looked at the hints and it gave me the formula, but I feel like that should have been given.
I do not work in the developing field yet, however I think that info would not be for you to figure out. I feel like if you worked at say NASA as a developer, the scientist would come say I need the computer to do this (x, y, z) and you would ask how to get that. I am assuming they would possibly tell you. Just like this case. "Hey I need the computer to calculate “orbital periods”, and you would go, “how do I get that?”, they then tell you. (Unless you were the developer and scientist).
So I completely understand your frustration. I was very annoyed with this algorithm when I first started and it took me 5 mins once I had the formula. And the worst part is I’m a nerd, I use to be president of Astronomy club and vp of the Chemistry club back when I was in school, and also took all these extra science classes that I didn’t have to because I liked it.
I just feel like I was losing so much time trying to find out the little things and not actually coding.
I love FCC, but dang all these algorithms back to back was killing me lol.
Thank you for that article. Was a life saver!
I think standard deviation would have been easier but also somewhat challenging. Astronomy is a little too hard.
Agree, i don’t quite understand the question either
I agree with this sentiment. Of all the possible algorithmic challenges, why is this one the final hurdle for the intermediate block? Is this not a course on Front-End Development? Why not have a challenge that concerns DOM elements?
It’s unlikely that web developers are going to solve physics problems. Why highlight one here? It seems out of place.
but you could find yourself with something you have no idea about, and have to do some research on your own
That is also the hurdle of programming
anyway, with curriculum 7.0 (released in phases during this here) there will be a complete overhaul of the challenges so this challenge will not be present anymore
@ilenia You’re right. I think I was just having an initial aversion to the problem because it was so far out of my domain. Good to hear there’s going to be an overhaul. Thank you!
EDIT May 30, 2020:
As JeremyLT has pointed out in the post following this one, when one object orbits another in an elliptical orbit, the object being orbited is not at the center of the ellipse, but located at one of the two foci, and so the average altitude is the correct value to use. Please ignore the remainder of this post, which I am leaving here only for clarity in case any other posts in this thread reference this one.
Actually, the formula given as a hint (Kepler’s third law), which is the same one that people are referring to in this thread, is not the correct formula.
Kepler’s third law is:
In that formula, a represents the semi-major axis, which can be found by adding the radius of the earth to the maximum altitude of the object orbiting it. If you represent the orbit as an ellipse, this would be the distance from the center of the ellipse to one of the two points furthest from the center. Given just the average altitude, I don’t think it’s actually possible to complete this challenge correctly.
See here. https://physics.stackexchange.com/a/459854
The semi major axis is not the maximum distance from the center of the earth.
The hardest part is deciphering the formula. Everything else is easy.
The formula is:
const time = 2 * Math.PI * Math.sqrt((earthRadius + arr.avgAlt) / GM);
In this case
a is the distance from the center of the earth to its surface + the avgAltitude (which would be the object circling the earth. On the same wiki page, it states
a is the sum of the semi-major and semi-minor axis. The puzzle is assuming the orbit is circular so there is no major and minor axis.
Imagine this picture
as the earth but circular. C would be the center point of the earth.,
a would be the radius and the avg altitude would be the point beyond the circle to the object (ie the satellite.)
Not quite. There is no assumption that the ellipse is circular. If the orbit was circular, then there would not be an average altitude.
I’ll expand on the post I linked.
In an elliptical orbit, the Earth is not at the center but rather one of the foci. The semi-major axis is actually the average distance to the foci. Therefore, Kepler’s third law applies.
In Kepler’s original notes, he actually uses the mean distance from the sun in his calculations with planetary orbital periods.
Look at my formula. It IS kepler’s third law. I used earthRadius + avgAlt as > a <.
I’ve already solved this problem with that formula so I’m not really sure why you’re saying it’s incorrect.
This is incorrect. That’s what I said in my previous post. The Earth is at F1 or F2 rather than at C. The formula is correct but your description is not.