All problems
Cylinder Min Surface
Problem
Minimize the total surface area S = 2*pi*r^2 + 2*pi*r*h of a closed cylinder with fixed volume V = pi*r^2*h.
Substituting h = V / (pi*r^2) gives S(r) = 2*pi*r^2 + 2*V/r, minimized at r = (V / (2*pi))^(1/3). Return [r, h, S_min]. For V <= 0 return [0.0, 0.0, 0.0]. Use 3.141592653589793 for pi.
Hint
At the optimum the height equals the diameter, h = 2r.
Test cases
case 1
in: [6.283185307179586]
expected: [1,2,18.84955592153876]
case 2
in: [50.26548245743669]
expected: [2,4,75.39822368615503]
case 3
in: [169.64600329384882]
expected: [3,6,169.64600329384882]
case 4
in: [0]
expected: [0,0,0]
Starter codePython
def cylinder_min_surface(v):
# Return [radius, height, min_surface_area]
# Your code here
pass4 test cases · run your code against them in the editor