Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
math solution in Clear category for Humpty Dumpty Form by Olpag
from math import asin, log, pi, sqrt
def checkio(height, width):
a, b = width / 2, height / 2
if a < b: # Prolate
S = 2*pi*a*(a + b*b / sqrt(b*b - a*a) * asin(sqrt(b*b - a*a) / b))
elif a > b: # Oblate
S = 2*pi*a*(a + b*b / sqrt(a*a - b*b) * log((a + sqrt(a*a - b*b)) / b))
else: # Sphere
S = 4 * pi * a * b
V = 4/3 * pi * a**2 * b
return [round(V,2), round(S,2)]
Sept. 11, 2019
Comments: