Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Humpty Dumpty Form by s_o_va
import math
def checkio(height, width):
if height == width:
s = round(4*math.pi*(height/2)**2, 2)
else:
if width > height:
e = (1 - (height/2)**2/(width/2)**2)**(1/2)
s = round(2 * math.pi * (width/2)**2 + math.pi * (height/2)**2 / e * math.log((1+e)/(1-e)), 2)
else:
e = (1 - (width/2)**2/(height/2)**2)**(1/2)
s = round(2 * math.pi * (width/2)**2 * (1 + (height/2) / ((width/2)*e) * math.asin(e)), 2)
return [round(math.pi/6 * width**2 * height, 2), s]
Sept. 10, 2018
Comments: