MathGroup Archive 1994

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

Search the Archive

Re: Unique List

  • To: mathgroup at christensen.cybernetics.net
  • Subject: [mg367] Re: [mg358] Unique List
  • From: Count Dracula <lk3a at kelvin.seas.virginia.edu>
  • Date: Tue, 27 Dec 1994 16:04:55 -0500

 "Love" == Robert B Love <rlove at raptor.rmNUG.ORG> writes:

    Love> OK, time for a little fun.  I can generate a list of random
    Love> integers as Table[Random[Integer,{1,42}],{6}] and I get a list 6
    Love> elements long containing the integers from 1 to 42.  But how do I
    Love> make sure no elements are repeated.

    Love> I'm trying to simulate a lottery pick of 6 numbers between 1 and
    Love> 42 but no repeats are allowed.  Any clever tricks to get a list
    Love> with no members repeated?

    Love> Thanx, Good Luck and Happy New Year to all.



Try the Combinatorica package in the DiscreteMath directory:


In[2]:= <<DiscreteMath`Combinatorica`

In[3]:= RandomKSubset[Range[1,42], 6]

Out[3]= {13, 15, 16, 21, 31, 33}

In[4]:= RandomKSubset[Range[1,42], 6]

Out[4]= {2, 12, 26, 36, 41, 42}





 ___________________________________________________________________________________
 Levent Kitis           lk3a at cars.mech.virginia.edu    lk3a at kelvin.seas.virginia.edu
 University of Virginia  Department of Mechanical, Aerospace and Nuclear Engineering  
 ___________________________________________________________________________________



  • Prev by Date: Generating Lottery Numbers
  • Next by Date: Re: Unique List
  • Previous by thread: Unique List
  • Next by thread: Re: Unique List