Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'Subsets' topicStudent Support Forum > General > Archives > "Subsets"

< Previous CommentHelp | Reply To Comment | Reply To Topic
Author Comment/Response
jf
03/21/13 12:36pm

RandomSample is exactly what you want.

Since your keyboard is too old to have lower-case letters, you might have an old Mathematica, too.

In 5.2,

In[7]:=x=20;
lst = Range[x,1,-1]

Out[8]= {20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1}

To take 3-element subsets:

In[9]:= Table[ lst[[ Random[Integer,{1,x}]]],{3}]

Out[9]=
{15,1,19}

You could do something with Union and Take to eliminate duplicates.


URL: ,

Subject (listing for 'Subsets')
Author Date Posted
Subsets Andre Moreira 03/20/13 11:01pm
Re: Subsets jf 03/21/13 12:36pm
< Previous CommentHelp | Reply To Comment | Reply To Topic