L=[(0,0,0,0,3,4,8,0,0,3,7,3,0,18,0,0,0)] j=0 n=0 H=23 for r in range(9): NL=[] for par in sorted(L,key=lambda x:x[16]): a=par[0] b=par[1] c=par[2] for h in (0,1): if par[3+5*h]!=min(par[3],par[8]): continue for g in (0,1,2): p=par[g] if p>=3: continue i=base[g]+p lot=lots[i] dh=lot[1+h] xm=lot[3+2*h] xp=lot[4+2*h] bh=lot[7+h] D=lot[9] rho=lot[10] mh=par[5+5*h] ph=par[6+5*h] sh=par[7+5*h] fh=par[4+5*h] j=j+1 sel=-1 for k in (0,1,2): if k==0: bm=mh bp=ph de=0 e=0 elif k==1: if h==0: bm=(2*mh)//3 bp=ph//2 de=5 else: bm=mh//2 bp=(2*ph)//3 de=6 e=sum((6,h,mh,ph))-bm-bp else: bm=0 bp=0 de=12-h e=sum((14,-h,mh,ph)) u=sh if k==0 and g==fh else 0 d=dh-alpha[g]*u M=sum((bm,xm-beta_m[g]*u)) P=sum((bp,xp-beta_p[g]*u)) if ok_in(g,bm,bp) and ok_post(h,M,P): sel=k break