AW: Rearrangement of a sequence into random order
- To: mathgroup at smc.vnet.net
- Subject: [mg28471] AW: [mg28434] Rearrangement of a sequence into random order
- From: Stefan.Schenderlein at ferring.de
- Date: Fri, 20 Apr 2001 04:24:19 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Hi Loren, I think this is exactly what you want. You can find the example in the HelpBrowser for Built-in Functions. It is the last example on the page. Stefan The defined function RandomRelist gives a list with the same members as the input list, but in a random reordering. RandomRelist[x_List]:= Block[{n=x,p}, = Do[p=Random[Integer,{1,i}];n[[{p,i}]]=n[[{i,p}]],{i,Length[x]}];n] In[16]:= RandomRelist[Range[15]] Out[16]= {9,15,8,11,2,10,6,13,12,14,4,3,7,5,1} > -----Urspr=FCngliche Nachricht----- > Von: Loren Dill [SMTP:lorendill at mediaone.net] > Gesendet am: Mittwoch, 18. April 2001 09:24 > An: mathgroup at smc.vnet.net > Betreff: [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 >