which library has map reduce and how to use it for this case

Ho Yeung Lee davidbenny2000 at gmail.com
Thu Jun 9 02:52:24 EDT 2016


i got M1 to M5 and V6 operator

and would like to do a full combination and result will also act among each other, 

map reduce attract my application

how to use this in this example?

actually below is like vlookup
then example is op3(op2(op1(x->y, y->z)), x->z)

search which combinations will result in a column result is 1


M1 = {}
M2 = {}
M3 = {}
M4 = {}
M5 = {}
V6 = {}
M1['00']=0
M1['01']=1
M1['02']=1
M1['10']=1
M1['11']=1
M1['12']=1
M1['20']=1
M1['21']=1
M1['22']=1
M2['00']=0
M2['01']=0
M2['02']=1
M2['10']=0
M2['11']=1
M2['12']=1
M2['20']=1
M2['21']=1
M2['22']=1
M3['00']=0
M3['01']=0
M3['02']=0
M3['10']=0
M3['11']=1
M3['12']=1
M3['20']=0
M3['21']=1
M3['22']=1
M4['00']=0
M4['01']=1
M4['02']=0
M4['10']=1
M4['11']=1
M4['12']=1
M4['20']=0
M4['21']=1
M4['22']=1
M5['00']=0
M5['01']=0
M5['02']=0
M5['10']=0
M5['11']=1
M5['12']=1
M5['20']=0
M5['21']=1
M5['22']=1
V6['00']=1
V6['01']=1
V6['02']=1
V6['10']=1
V6['11']=1
V6['12']=1
V6['20']=0
V6['21']=1
V6['22']=1
MM = {}
MM[0] = M1
MM[1] = M2
MM[2] = M3
MM[3] = M4
MM[4] = M5
MM[5] = V6
m = 3
b = [str(i)+str(j)+str(k) for i in range(m) for j in range(m) for k in range(m)]
b[21][0:1]+b[21][1:2]
b[21][1:2]+b[21][2:3]
b[21][0:1]+b[21][2:3]

#def node(mmm, A):
 #H2 = [MM[mmm][b[i][0:1]+b[i][1:2]] for i in range(len(b))]
 #return H2

#node(5, b[i][0:1]+b[i][1:2])


H2 = [MM[5][b[i][0:1]+b[i][1:2]] for i in range(len(b))]
H3 = [MM[5][b[i][0:1]+b[i][1:2]] for i in range(len(b))]
[str(k)+str(v) for k, v in zip(H2, H3)]

import itertools
deep = 3

finalresult = []
def DFS(H2, H3, b, deep, mresult)
 mylist = [i for i in range(0,7-1)]
 for aa,bb in itertools.combinations(mylist, 2):
  print(aa,bb)
  if deep == 3:
   #op0, op1
   op1xy = [MM[aa][b[i][0:1]+b[i][1:2]] for i in range(len(b))]
   op1yz = [MM[aa][b[i][1:2]+b[i][2:3]] for i in range(len(b))]
   op1xz = [MM[aa][b[i][0:1]+b[i][2:3]] for i in range(len(b))]
   op2xy = [MM[bb][b[i][0:1]+b[i][1:2]] for i in range(len(b))]
   op2yz = [MM[bb][b[i][1:2]+b[i][2:3]] for i in range(len(b))]
   op2xz = [MM[bb][b[i][0:1]+b[i][2:3]] for i in range(len(b))]
   mresult.append(op1xy)
   mresult.append(op1yz)
   mresult.append(op1xz)
   mresult.append(op2xy)
   mresult.append(op2yz)
   mresult.append(op2xz)
  else:
   H1 = H2
   H9 = H3
  ba = b
  b = [str(k)+str(v) for k, v in zip(H2, H3)]
  DFS(H1, H9, b)
  b = ba

DFS(0, 0, 0, 3, finalresult)



More information about the Python-list mailing list