Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
quick math solution in Clear category for Humpty Dumpty Form by MrPod
from math import asin, log, pi
def checkio(h, w):
h, w = h / 2, w / 2
e = lambda a, c: (1 - (a / c)**2)**.5
if h > w:
S = 2 * pi * w**2 * (1 + (h * asin(e(w, h)) / (e(w, h) * w)))
elif h == w:
S = 4 * pi * h**2
else:
S = 2 * pi * w**2 + pi * h**2 / e(h, w) * log((1 + e(h, w)) / (1 - e(h, w)))
return [4 * pi / 3 * w**2 * h, S]
July 28, 2018
Comments: