Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Look it up! solution in Clear category for Humpty Dumpty Form by nickie
from math import sqrt, pi, asin, atanh
# http://en.wikipedia.org/wiki/Spheroid
def checkio(c, a):
a, c = a/2, c/2
if c < a: # oblate
e = sqrt(1-(c/a)**2)
s = 2 * pi * a**2 * (1 + (1 - e**2) / e * atanh(e))
elif c > a: # prolate
e = sqrt(1-(a/c)**2)
s = 2 * pi * a**2 * (1 + c / a / e * asin(e))
else: # sphere
s = 4 * pi * a**2
v = 4 * pi / 3 * a**2 * c
return [round(v, 2), round(s, 2)]
Feb. 6, 2014
Comments: