> On Mar 29, 2018, at 6:48 PM, Ranjan Maitra <mai...@email.com> wrote:
> 
> Dear friends,
> 
> I would like to get all possible arrangements of n objects listed 1:n on a 
> circle.
> 
> Now this is easy to do in R. Keep the last spot fixed at n and fill in the 
> rest using permuations(n-1, n-1) from the gtools package.
> 
> However, what if clockwise or counterclockwise arrangements are the same? I 
> know that half of the above (n - 1)! arrangements are redundant.
> 
> Is there an easy way to list these (n-1)!/2 arrangements? 
> 

Well half of these arrangements will be of the form 

        `k, ... , j, n' 

and half will be of the form 

        `j, ...,  k, n'

So fix n in position n, select (k,j), and require that the first position is 
min(k,j) and position n-1 is max(k,j). 

There are choose(n-1,2) choices for {(k,j):k<j!=n}. Then you have (n-3)! ways 
to fill the rest. 

That gives (n-1)!/((n-3)! * 2!) * (n-3)! = (n-1)!/2 arrangements.

HTH,

Chuck

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to