1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| A=[5.5,1.05,0.6,6.4]
B=[3.2,6.1,7.8,4.13]
def PartiesDe(E):
P=[[]]
yield P
while E:
P=[x+[a] for x in P for a in E if all(a>y for y in x) ]
yield P
return
def Eval(X,K):
L=[K[i] for i in X]
return 0 if L==[] else reduce(lambda x,y:x+y,L)
def EvalAB(C):
return Eval(C[0],A)+Eval(C[1],B)
def main():
E=[0,1,2,3]
P=PartiesDe(E)
L=[]
for i in range(0,len(E)):
L+=P.next()
M=[ [X,Y] for X in L for Y in L if not any ([x in Y for x in X])]
R=[Z for Z in M if EvalAB(Z)==8.98]
print R
if __name__ == '__main__':
main() |
Partager