Thanks to everyone for the itertools hint; that sounds like it will work. Sorry I was not clearer: 1. Order matters; I meant to say that direction does not. That is, 123 is not the same as 213, but 123 is the same as 321 since the second example is simply a reversal. 2. I am looking for all permutations and subpermutations (if that is a word) of 1-n where the list must have at least 2, but no more than n, unique numbers (so 1 is not valid, nor is 1231 since it repeats 1 and is too long for n=3). I hope that makes sense. However, hopefully itertools will do it; if I run into problems I will respond to this email to keep it in the same thread. Thanks again! Oh, to the person who asked, I have 2.6 and 2.7 installed, with the default being 2.6.
On 12/1/10, bob gailer <bgai...@gmail.com> wrote: > On 12/1/2010 5:45 PM, Alex Hall wrote: >> Hi all, >> I am wondering if there is a python package that will find >> permutations? For example, if I have (1, 2, 3), the possibilities I >> want are: >> 12 >> 13 >> 23 >> 123 >> 132 >> 231 >> >> Order does not matter; 21 is the same as 12, but no numbers can >> repeat. If no package exists, does someone have a hint as to how to >> get a function to do this? The one I have right now will not find 132 >> or 231, nor will it find 13. TIA. > > According to Wikipedia " there are six permutations of the set {1,2,3}, > namely [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], and [3,2,1]." > > Above you show some "combinations" and a subset of the permutations. > > What rules did you apply to come up with your result? > > -- > Bob Gailer > 919-636-4239 > Chapel Hill NC > > -- Have a great day, Alex (msg sent from GMail website) mehg...@gmail.com; http://www.facebook.com/mehgcap _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor