Cody

# Problem 1428. Find the optimal shape to bring the maximum product by a given perimeter

Solution 2170066

Submitted on 22 Mar 2020 by Nikolaos Nikolaou
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
p = 5; [Nopt,prd] = max_product(p); assert(isequal(Nopt,3)) assert(abs(prd - 4.62962962962963)/4.62962962962963 < 1e-13)

prd = 4.629629629629630e+00

2   Pass
p = 10; [Nopt,prd] = max_product(p); assert(isequal(Nopt,4)) assert(abs(prd - 39.0625)/39.0625 < 1e-13)

prd = 3.906250000000000e+01

3   Pass
p = 17.5; [Nopt,prd] = max_product(p); assert(isequal(Nopt,6)) assert(abs(prd - 615.631438413601)/615.631438413601 < 1e-13)

prd = 6.156314384136015e+02

4   Pass
p = 29; [Nopt,prd] = max_product(p); assert(isequal(Nopt,11)) assert(abs(prd - 4.276204243443044e+04)/4.276204243443044e+04 < 1e-13)

prd = 4.276204243443044e+04

5   Pass
p = 49; [Nopt,prd] = max_product(p); assert(isequal(Nopt,18)) assert(abs(prd - 6.739448339947788e+07)/6.739448339947788e+07 < 1e-13)

prd = 6.739448339947788e+07

6   Pass
p = 256; [Nopt,prd] = max_product(p); assert(isequal(Nopt,94)) assert(abs(prd - 7.953137683223010e+40)/7.953137683223010e+40 < 1e-13)

prd = 7.953137683223010e+40

7   Pass
p = 1000000; [Nopt,prd] = max_product(p); assert(isequal(Nopt,367879)) assert(isinf(prd))

prd = Inf Nopt = 367879