There is that famous riddle:
A bear walks 1 km south, 1 km east and 1 km north, and comes to the place it started from. What color is the bear?
This one is very old, so I'll generalize it:
A bear walks
ykm east and
xkm north, and comes to the place it started from. This bear thinks that the North Pole is boring, so it never goes there. Which latitude did it start and end at?
Assume that the bear is an idealized point, and the Earth is a perfect sphere with 10000 km distance from the pole to the equator (however, you can use a more accurate model if it's easier for some reason).
Write a program or a subroutine that receives the two numbers
y, and prints or returns the latitude.
- Input with at least 3 decimal places of precision should be supported
- Input is in the range (0...99999), bounds not inclusive
- If the situation is physically impossible, print an empty string or a message, or return an impossible value (like 91 or
NaN- or, in fact, 90 - since 90 is an impossible value)
- You should print the most northern (maximal) latitude that satisfies the conditions, except the North Pole. If the North Pole is the only solution, see above.
- Output precision should be like IEEE single precison or better (24 bits or 7 decimal digits of precision).
- If the output is printed, use decimal notation (e.g. -89.99 for a point near the South Pole) . If the output is returned, use floating-point or fixed-point notation.
Shortest code in bytes wins.