Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Humpty Dumpty Form by Moff
import math
def checkio(h, w):
c = h / 2
a = w / 2
if a == c: # sphere
s = 4 * math.pi * a * a
elif c < a: # oblate
e2 = 1 - (c / a) ** 2
e = math.sqrt(e2)
s = 2 * math.pi * a * a * (1 + (1 - e2) / e * math.atanh(e))
elif c > a: # prolate
e2 = 1 - (a / c) ** 2
e = math.sqrt(e2)
s = 2 * math.pi * a * a * (1 + c * math.asin(e) / a / e)
v = a * a * c * 4 * math.pi / 3
return [round(v, 2), round(s, 2)]
July 24, 2015