Re: random numbers

new topic     » goto parent     » topic index » view thread      » older message » newer message

Jason Gade wrote:
> I would only change it slightly:
> }}}
<eucode>
> s = {1,2,3,4,5,6,7,8,9,...52}
> n = repeat(0, 52)
> for t=1 to 52 do
>    r = rand(length(s)) -- grab a random position
>    n[t] = s[r] -- add it to our new sequence
>    s = s[1..r-1] & s[r+1..$] -- remove from available numbers
> end for
> </eucode>
{{{


Good eye! :)

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu