python3 <<'PY' import math a=0.25; b=1.0/12 def Arows(y1,y2): q=a+b-y1; q2=b+a-y2 return math.sqrt(a*a*q)+math.sqrt(max(0,b*q*(q-a)))+math.sqrt(b*b*q2)+math.sqrt(max(0,a*q2*(q2-b))) def Acols(y1,y2): q=a+b; q2=2*a+2*b-y1-y2-q return math.sqrt(q)*(a+b)+math.sqrt(max(0,q2))*(math.sqrt(max(0,b*(b-y1)))+math.sqrt(max(0,a*(a-y2)))) def opty3(y1,y2): lo=0.0; hi=a; gr=(math.sqrt(5)-1)/2 def f(y3): beta=a+b-y3; B=math.sqrt(beta)*(b+math.sqrt(max(0,a*(a-y3)))) gam=y1+y2+y3; C=math.sqrt(gam)*(math.sqrt(max(0,b*y1))+math.sqrt(max(0,a*y2))+math.sqrt(max(0,a*y3))) return B+C for _ in range(80): c=hi-gr*(hi-lo); d=lo+gr*(hi-lo) if f(c)best: best=tot; arg=(y1,y2,A,tot) print(name,best,arg,"1-best",1-best) PY