Velocity Reviews > Random numbers select

# Random numbers select

polilop
Guest
Posts: n/a

 11-13-2005
I have 30 numbers. I need to select randomly 10 out of the given 30. A
number must not repeat ( eg. i can't have number 10 twice ). How can i do
this??

Evertjan.
Guest
Posts: n/a

 11-13-2005
polilop wrote on 13 nov 2005 in microsoft.public.inetserver.asp.general:

> I have 30 numbers. I need to select randomly 10 out of the given 30. A
> number must not repeat ( eg. i can't have number 10 twice ). How can i
> do this??
>

Fill an array with thos numbers and randomly select from tha array,
emptying the taken places.

If the next selection is empty, try again.

Show your code, if it does not work.

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Bob Lehmann
Guest
Posts: n/a

 11-13-2005
> If the next selection is empty, try again.
This can be extremely slow, especially as the number of already selected
items grows.

The typical shuffle algorithim selects an item from the array between 0 and
the upper bound of the array, moves it the end of the array, or removes it
altogether, then selects the next item from from the array with a range
between 0 and the upper bound of the array - 1.

Here's a VBScript example -
http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=114

Bob Lehmann

"Evertjan." <(E-Mail Removed)> wrote in message
news:Xns970DE5B2D58E5eejj99@194.109.133.242...
> polilop wrote on 13 nov 2005 in microsoft.public.inetserver.asp.general:
>
> > I have 30 numbers. I need to select randomly 10 out of the given 30. A
> > number must not repeat ( eg. i can't have number 10 twice ). How can i
> > do this??
> >

>
> Fill an array with thos numbers and randomly select from tha array,
> emptying the taken places.
>
> If the next selection is empty, try again.
>
> Show your code, if it does not work.
>
> --
> Evertjan.
> The Netherlands.
> (Replace all crosses with dots in my emailaddress)
>

PJones
Guest
Posts: n/a

 11-27-2005
http://www.powerasp.com/content/code...randomizer.asp

"polilop" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I have 30 numbers. I need to select randomly 10 out of the given 30. A
>number must not repeat ( eg. i can't have number 10 twice ). How can i do
>this??
>