members I am facing problem to do the following in Python. I have input as follows
Input {(1, 2): [(2,), (1,)], (1, 3): [(3,), (1,)], (2, 3): [(2,), (3,)],
(1,): [1], (2,): [2], (3,): [3], (1, 2, 3): [(1, 2), (3,)]}
Now the output should be
(1,2,3=(2),(1),(3).
It needs to check the Input key (1,2,3) and its corresponding value is [(1,2),(3)] again it looks for (1,2) in input array and it finds value corresponding to (1,2) is (2) and (1). Any idea how to do it.My code is not working perfectly.
I need your help regarding this.
def OptimalPartition(L=[],tempdict=dict()):
global ret
L=tuple(L)
chk0=tempdict.get(L[0])
chk1=tempdict.get(L[1])
if len(tuple([chk0]))==1:
print(L[0])
ret.append(chk0)
else:
OptimalPartition(list(L[0]),tempdict)
if len(tuple([chk1]))==1:
print(L[1])
ret.append(chk1)
else:
OptimalPartition(list(L[1]),tempdict)