python - How to tell if any element in a list of combinations is in a specific set in the most efficient way? -


here mean question:

j = [1,2,3,4,5,6,7] k = [1,2,3,4,5,6,7]  #i want generate possible pairs of pairs these 2 lists,  example:  p1 = (1,1) p2 = (2,2) paira = (p1,p2) # (1,1),(2,2) #this mean pair of pair  #this i've got far:  sa = set()         #this has lot of pairs of pairs in sa.add(...) #...  item in permutations(j):     m1,m2 in combinations(zip(item,k),2):            if (m1,m2) in sa:   # want know                                 # if pair(of pairs)                                 # combination produces                                 # in set sa                #do stuff            else:                #do other stuff 

this part of code scales badly number of elements in list j,k increases. wonder there specific way in python make more efficient in terms of performance or cleaner in style. looks clumsy me.

any idea , advice appreciated! in advance!


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -