Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2007
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: All permutations of a sequence

  • To: mathgroup at smc.vnet.net
  • Subject: [mg76362] Re: All permutations of a sequence
  • From: osbornc at gmail.com
  • Date: Sun, 20 May 2007 02:35:10 -0400 (EDT)
  • References: <f2h8t7$v4$1@smc.vnet.net>

On May 17, 4:56 am, Virgil Stokes <v... at it.uu.se> wrote:
> I would like to get all unique permutations of a sequence (e.g.
> {1,2,3,4,5,6,7,8,9,10,11,12,13}) with the constraint that all sequences
> that have an opposite ordering are not included (e.g. {13, 12,
> 11,10,9,8,6,5,4,3,2,1}) would not be included.
>
> Are there some Mathematica commands that can be used to efficiently
> generate these permutations?
>
> --V. Stokes

Hi Virgil,

Select[Permutations[x], ((First[#] <= Last[#]) &)]



Here x is your list.

You will get the permutations where the first element is less than or
equal to the last.
This fails your criteria if you have some element in your list twice.

Assuming no element is used more than once, then there is a bijection
between
the permutations that satisfy ((First[#] <= Last[#]) &) and those that
do not
(you can go from a permutation to its "twin" by reversing it).

Using <= instead of < should make it handle single-element lists
correctly.

This does not require the Combinatorica package, at least not in
version 6.0.

Cheers,
Chris



  • Prev by Date: Re: 64-bit again
  • Next by Date: Re: Style sheets in 6.0
  • Previous by thread: Re: All permutations of a sequence
  • Next by thread: Re: All permutations of a sequence