Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

listing all those pairs of tuples which are permutations of each other

Suppose I have a list of tuples like

import itertools
l=range(0,6)
m=itertools.combinations(1,2)
list(m)

How do I get those pairs of tuples (i,j);(x,y) such that (i,j)=(y,x)? Also, is there a way to generalize this, that is, I would to have pairs of tuples (a,b,c,...);(x,y,z...) such that (a,b,c...)=(z,y,x...). Is there any efficent way of doing this? Thanks beforehand.

listing all those pairs of tuples which are permutations of each other

Suppose I have a list of tuples like

import itertools
l=range(0,6)
m=itertools.combinations(1,2)
m=itertools.combinations(l,2)
list(m)

How do I get those pairs of tuples (i,j);(x,y) such that (i,j)=(y,x)? Also, is there a way to generalize this, that is, I would to have pairs of tuples (a,b,c,...);(x,y,z...) such that (a,b,c...)=(z,y,x...). Is there any efficent way of doing this? Thanks beforehand. beforehand.