Welcome to Project Lovelace! We're still in early development so there are still tons of bugs to find and improvements to make.
If you have any suggestions, complaints, or comments please let us know on Discourse, Discord, or GitHub!
Light is really fast: 299,792,458 meters per second to be exact. That's fast enough to make it almost 7.5 times around
the Earth in one second! A spacecraft would take a few days to reach the Moon, but a beam of light could do it in
1.255 seconds.
We can calculate how long it takes a beam of light to reach places in space. Since light travels at a constant speed
$c$, the time $t$ it takes to travel a distance $d$ is $t = d/c$. Try to submit some code with a function
light_time(distance) that returns the time it takes light to travel that distance.
Input:
A distance in meters (m).
Output:
The time it takes for light to travel the input distance, in seconds (s).
The speed of light is usually denoted by lowercase $c$, apparently for "constant" or from the
Latin celeritas meaning quickness or swiftness.
Light takes 1.255 seconds to travel from the surface of the Earth to the surface of the Moon. The average
distance between the Earth and Moon is 384,400 km but the radius of the Earth is 6,371 km and the radius of the
Moon is 1,737 km, so in this case light actually travels 384,400 - 6,371, - 1,737 = 376,292 km.
The first measurement
of the speed of light was made in 1676 by Ole Rømer but scientists argued about whether the speed of light
was finite or infinite for a long time.
Let us know what you think about this problem! Was it too hard? Difficult to understand? Also feel free to
discuss the problem, ask questions, and post cool stuff on Discourse. You should be able see a discussion
thread below. Would be nice if you don't post solutions in there but if you do then please organize and
document your code well so others can learn from it.