# Revision history [back]

You don't need to consider all permutations - it's enough to take just one suitable permutation and multiply it by elements of the stabilizer of $A$.

You don't need to consider all permutations - it's enough to take just one suitable permutation and multiply it by iterate over the elements of the stabilizer of $A$.

You don't need to consider all permutations - it's enough to iterate over the elements of the stabilizer of $A$.$A$.times the elements of the stabilizer of $B$.

You don't need to consider all permutations - it's enough to iterate over the take one suitable permutations and multiply it by elements of the stabilizer stabilizers of $A$.times the elements of the stabilizer of $A$ and $B$.

Here is an example:

def fixed_sets(L):
D = dict()
for p,l in enumerate(L):
D.setdefault(l,[]).append(p+1)
return [tuple(s) for s in D.values() if len(s)>1]

A=[1,1,2,3,3,4]
B=[12,9,10,15,15,14]

k = len(A)

S = SymmetricGroup(k)
SAB = S.subgroup(fixed_sets(A) + fixed_sets(B))

perm = S( Word(B).standard_permutation() / Word(A).standard_permutation() )

#testing can be done like this
#sortedB = sorted(B)
#assert set( zip(A,[sortedB[i-1] for i in perm.domain()]) ) == set( zip(A,B) )

W = WeylGroup('A'+str(k-1), prefix = 's')
winner =  max( (W(s*perm) for s in SAB), key=lambda s: s.length() )

print( winner )


You don't need to consider all permutations - it's enough to take one suitable permutations and multiply it by elements of the stabilizers of $A$ and $B$.

Here is an example:

# returns list of cycles generating the stabilizer of L
def fixed_sets(L):
D = dict()
for p,l in enumerate(L):
D.setdefault(l,[]).append(p+1)
return [tuple(s) for s in D.values() if len(s)>1]
D.values()]

A=[1,1,2,3,3,4]
B=[12,9,10,15,15,14]

k = len(A)

S = SymmetricGroup(k)
SAB = S.subgroup(fixed_sets(A) + fixed_sets(B))

perm = S( Word(B).standard_permutation() / Word(A).standard_permutation() )

#testing can be done like this
#sortedB = sorted(B)
#assert set( zip(A,[sortedB[i-1] for i in perm.domain()]) ) == set( zip(A,B) )

W = WeylGroup('A'+str(k-1), prefix = 's')
winner =  max( (W(s*perm) for s in SAB), key=lambda s: s.length() )

print( winner )


You don't need to consider all permutations - it's enough to take one suitable permutations and multiply it by elements of the stabilizers of $A$ and $B$.

Here is an example:

# returns list of cycles generating the stabilizer of L
def fixed_sets(L):
D = dict()
for p,l in enumerate(L):
D.setdefault(l,[]).append(p+1)
return [tuple(s) for s in D.values()]
D.values() if len(s)>1]

A=[1,1,2,3,3,4]
B=[12,9,10,15,15,14]

k = len(A)

S = SymmetricGroup(k)
SAB = S.subgroup(fixed_sets(A) + fixed_sets(B))

perm = S( Word(B).standard_permutation() / Word(A).standard_permutation() )

#testing can be done like this
#sortedB = sorted(B)
#assert set( zip(A,[sortedB[i-1] for i in perm.domain()]) ) == set( zip(A,B) )

W = WeylGroup('A'+str(k-1), prefix = 's')
winner =  max( (W(s*perm) for s in SAB), key=lambda s: s.length() )

print( winner )


You don't need to consider all permutations - it's enough to take one suitable permutations permutation and multiply it by elements of the stabilizers of $A$ and $B$.

Here is an example:

# returns list of cycles generating the stabilizer of L
def fixed_sets(L):
D = dict()
for p,l in enumerate(L):
D.setdefault(l,[]).append(p+1)
return [tuple(s) for s in D.values() if len(s)>1]

A=[1,1,2,3,3,4]
B=[12,9,10,15,15,14]

k = len(A)

S = SymmetricGroup(k)
SAB = S.subgroup(fixed_sets(A) + fixed_sets(B))

perm = S( Word(B).standard_permutation() / Word(A).standard_permutation() )

#testing # testing can be done like this
this:
#sortedB = sorted(B)
#assert set( zip(A,[sortedB[i-1] for i in perm.domain()]) ) == set( zip(A,B) )

W = WeylGroup('A'+str(k-1), prefix = 's')
winner =  max( (W(s*perm) for s in SAB), key=lambda s: s.length() )

print( winner )


You don't need to consider all permutations - it's enough to take one suitable permutation and multiply it by elements of the stabilizers of $A$ and $B$.

Here is an example:

# returns list of cycles generating the stabilizer of L
def fixed_sets(L):
D = dict()
for p,l in enumerate(L):
D.setdefault(l,[]).append(p+1)
return [tuple(s) for s in D.values() if len(s)>1]

A=[1,1,2,3,3,4]
B=[12,9,10,15,15,14]

k = len(A)

S = SymmetricGroup(k)
SAB SA = S.subgroup(fixed_sets(A) + fixed_sets(B))
S.subgroup(fixed_sets(A))
SB = S.subgroup(fixed_sets(B))

perm = S( Word(B).standard_permutation() / Word(A).standard_permutation() )

# testing can be done like this:
#sortedB = sorted(B)
#assert set( zip(A,[sortedB[i-1] for i in perm.domain()]) ) == set( zip(A,B) )

W = WeylGroup('A'+str(k-1), prefix = 's')
winner = max( (W(s*perm) (W(a*perm*n) for s a in SAB), SA for b in SB), key=lambda s: s.length() )

print( winner )


You don't need to consider all permutations - it's enough to take one suitable permutation and multiply it by elements of the stabilizers of $A$ and $B$.

Here is an example:

# returns list of cycles generating the stabilizer of L
def fixed_sets(L):
D = dict()
for p,l in enumerate(L):
D.setdefault(l,[]).append(p+1)
return [tuple(s) for s in D.values() if len(s)>1]

A=[1,1,2,3,3,4]
B=[12,9,10,15,15,14]

k = len(A)

S = SymmetricGroup(k)
SA = S.subgroup(fixed_sets(A))
SB = S.subgroup(fixed_sets(B))

perm = S( Word(B).standard_permutation() / Word(A).standard_permutation() )

# testing can be done like this:
#sortedB = sorted(B)
#assert set( zip(A,[sortedB[i-1] for i in perm.domain()]) ) == set( zip(A,B) )

W = WeylGroup('A'+str(k-1), prefix = 's')
winner = max( (W(a*perm*n) (W(a*perm*b) for a in SA for b in SB), key=lambda s: s.length() )

print( winner )


You don't need to consider all permutations - it's enough to take one suitable permutation and multiply it by elements of the stabilizers of $A$ and $B$.$B$ from left and right, respectively.

Here is an example:

# returns list of cycles generating the stabilizer of L
def fixed_sets(L):
D = dict()
for p,l in enumerate(L):
D.setdefault(l,[]).append(p+1)
return [tuple(s) for s in D.values() if len(s)>1]

A=[1,1,2,3,3,4]
B=[12,9,10,15,15,14]

k = len(A)

S = SymmetricGroup(k)
SA = S.subgroup(fixed_sets(A))
SB = S.subgroup(fixed_sets(B))

perm = S( Word(B).standard_permutation() / Word(A).standard_permutation() )

# testing can be done like this:
#sortedB = sorted(B)
#assert set( zip(A,[sortedB[i-1] for i in perm.domain()]) ) == set( zip(A,B) )

W = WeylGroup('A'+str(k-1), prefix = 's')
winner = max( (W(a*perm*b) for a in SA for b in SB), key=lambda s: s.length() )

print( winner )