Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Oh, Math! Up Yours! solution in Clear category for Humpty Dumpty Form by obone
def checkio(height, width):
from math import pi, sqrt, log, asin
a, c = width / 2, height / 2
v = 4 * pi * a ** 2 * c / 3
if a == c:
s = 4 * pi * a * c
elif a > c:
e = sqrt(1 - c ** 2 / a ** 2)
s = 2 * pi * a ** 2 + pi * c ** 2 / e * log((1 + e) / (1 - e))
else:
e = sqrt(1 - a ** 2 / c ** 2)
s = 2 * pi * a ** 2 * (1 + c / a / e * asin(e))
return [round(v, 2), round(s, 2)]
July 15, 2019