Re: General--Simple Permutations
- To: mathgroup at smc.vnet.net
- Subject: [mg70382] Re: [mg70333] General--Simple Permutations
- From: "Adriano Pascoletti" <pascolet at dimi.uniud.it>
- Date: Sun, 15 Oct 2006 00:18:44 -0400 (EDT)
andrew.and.liz at gmail.com wrote ..
> I would like to write a function that can look at a long list of permutations
> (an output from other calculations) and list, in cycle form, only the permutations
> that consist of 2 cycles or 3 cycles and leave the rest of the places alone.
> I am analyzing a permutation puzzle and am looking for short sequences
> of moves that switch a few places and leave the rest of the pieces in place.
> Any help would be appreciated!
>
Andrew,
look at the function ToCycles in the Combinatorica package
In[1]:=
<< "DiscreteMath`Combinatorica`"
In[2]:=?ToCycles
ToCycles[p] gives the cycle structure of permutation p as a list of cyclic \
permutations.
then evaluate
Cases[<long listof perms>,p_/;2≤Length[ToCycles[p]]≤3]
For instance
In[4]:=
Cases[Permutations[3], p_ /; 2 <= Length[ToCycles[p]] <= 3]
Out[4]=
{{1, 2, 3}, {1, 3, 2}, {2, 1, 3}, {3, 2, 1}}
and
In[5]:=
Cases[Permutations[4], p_ /; 2 <= Length[ToCycles[p]] <=
3]
Out[5]=
{{1,2,4,3},{1,3,2,4},{1,3,4,2},{1,4,2,3},{1,4,3,2},{2,1,3,4},{
2,1,4,3},{2,3,1,4},{2,4,3,1},{3,1,2,4},{3,2,1,4},{3,2,4,1},{
3,4,1,2},{4,1,3,2},{4,2,1,3},{4,2,3,1},{4,3,2,1}}
Adriano Pascoletti