Re: random numbers
- Posted by c.k.lester <euphoric at ckle?t?r.com> Nov 22, 2007
- 576 views
Allen Ashby wrote: > > I am trying to generate 52 random numbers 1-52 without duplicating any > numbers. > it seems every time I try I get duplications. Does anyone have a > solution for this. Start with a sequence {1..52} and pull them from that. s = {1,2,3,4,5,6,7,8,9,...52} n = {} for t=1 to 52 do r = rand(length(s)) -- grab a random position n &= s[r] -- add it to our new sequence s = s[1..r-1] & s[r+1..$] -- remove from available numbers end for