On Saturday, March 5, 2011 5:42:21 AM UTC, Jason Grout wrote: > On 3/4/11 11:38 PM, Santanu Sarkar wrote: > > How one can generate random permutation over the set > > A={1,2,...,50}? > > > > > I think this does it: > > sage: Permutations(50).random_element() > [11, 4, 30, 48, 49, 36, 22, 16, 27, 6, 44, 33, 13, 50, 9, 35, 15, 12, > 26, 45, 1, 18, 2, 40, 19, 10, 28, 7, 37, 46, 25, 29, 34, 41, 38, 24, 8, > 20, 32, 21, 14, 23, 31, 47, 43, 17, 3, 39, 5, 42] > > > Jason
Hi I have a set of size (say) 50 and I would like to generate a randomly-ordered list of its elements. The trouble is, if I use Permutations(my_set).random_element() it seems to want to generate the whole lot of them before picking out a random one!! Sorry but I cannot find how else to invoke this functionality, but I know there must be a better way .... thanks a lot -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support?hl=en. For more options, visit https://groups.google.com/groups/opt_out.