MathGroup Archive 2001

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

Search the Archive

Re: Rearrangement of a sequence into random order

  • To: mathgroup at smc.vnet.net
  • Subject: [mg28444] Re: [mg28434] Rearrangement of a sequence into random order
  • From: Tom De Vries <tdevries at shop.westworld.ca>
  • Date: Thu, 19 Apr 2001 03:26:32 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Hello Loren,

I had this in my files.   It uses Sort and an ordering function....   it's
probably one of many ways of doing this....  maybe it will do what you need
it to....

In[64]:=
scramble[list_] := Sort[list, (Random[Integer] == 1) &]

In[65]:=
scramble[{1, 2, 4, 5, 6, 7, 8, 9}]

Out[65]=
{9, 7, 4, 6, 8, 5, 2, 1}

In[66]:=
scramble[Range[20]]

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

Sincerely,

Tom De Vries


> From: "Loren Dill" <lorendill at mediaone.net>
To: mathgroup at smc.vnet.net
> Date: Wed, 18 Apr 2001 03:23:38 -0400 (EDT)
> To: mathgroup at smc.vnet.net
> Subject: [mg28444] [mg28434] Rearrangement of a sequence into random order
> 
> Hi,
> 
> I'm a math teacher, and need to prepare exams from time to time.  I
> typically prepare questions for the exam in a sequential order starting at
> the beginning of the material and going to the end.  I may have something
> like 20 short-answer questions.  I want a program that will randomize the
> order of the questions.  In other words, I want to provide n, the number of
> questions, and have the program provide a list of length n that contains all
> the numbers from 1 to n in a random order without any number being repeated
> or omitted.  I'm sure that this is an easy task for Mathematica, but I can't
> figure out the best way to do it.
> 
> Loren Dill
> 
> 
> 




  • Prev by Date: Re: Rearrangement of a sequence into random order
  • Next by Date: Re: Rearrangement of a sequence into random order
  • Previous by thread: Re: Rearrangement of a sequence into random order
  • Next by thread: Re: Re: Rearrangement of a sequence into random order