Here you have a few ideas:
The key-point here is to make things in such a way that the results
are really random. I suggest to you this:
1.- You make an 10x9 array with all the numbers you need:
Data_list[i,j]:=i*10+j
2.- you unsorted them ramdomly, but you keep them grouped as
decades. This means: you unsorted the first ten numbers but keep
them in the first ten places, then the next ten numbers, and so on.
At the end you will have something like:
4,6,5,7,3,10,2,9,8,1,
13,16,14,15,12,18,17,19,11,20,
24,23,26,30,25,21,28,29,27,22,
etc�
to do this you can create two different numbers of a certain decade
and then inter-exchange the positions of them. Repeat the process a
certain amount of times; 100, for example.
3.- then, to select numbers to compose a raffle, you make another
random election into a loop:
-initialize 9 variables to 0 to keep track of how many
numbers of a certain decade you used in the raffle you are creating:
used_from_row[n]:= 0
-initialize 9 variables to keep track of the amount of
unused numbers from every decade. All to 0.
still_not_used[0..8]:=0
-initialize one variable to keep track of the amount of the
numbers selected so far:
extractions:=0
-initialize your raffle:
raffle[0..14]:=0
-start the loop
repeat
-generate a random number between 0 and 9
row:= random(0..9)
-if the used numbers of this row are less than 3 (in the
raffle you are creating) and there are still numbers available from
this decade, proceed. If not, loop and generate a new random number
(yes, we will improve this later�).
if (used_from_row[row]< 3) and (still_not_used[row]>0)
then begin
-choose the last number of this decade from the matrix.
Raffle[extractions]:=Data_list[row, still_not_used[row] ]
-Decrease the control of used numbers of this decade
Dec ( still_not_used[row]);
-Increase the counter of used numbers of this row in this
raffle
Inc(already_used[row]);
-Increase the amount of numbers you extracted
Inc(extractions)
-Repeat this until you have extracted 15 numbers
Until (extractions=15)
You will end up having in raffle[0..15] a list of random numbers
with the requirements you needed. Then you sort them in order. To
print them in the proper way is trivial, as there are 1 to 3 numbers
of every decade.
You will need to re-loop to extract another raffle. Before this, you
will reset the values of already_used[0..n] to 0, but you will keep
the values of still_not_used[0..n]. This way, you keep extracting
different numbers for every raffle in a certain ticket.
I don't understand correctly your point 5. Anyway, you can have
more than one "data origin" as far as a certain number exists only
and only either in the random matrix or in your sets of numbers.
I'm afraid your point 6 is not correct. You meant 1..10 in the
first row, not 1..9
Improvements: To speed up the extraction, you can keep track of the
decades where you already extracted 3 numbers and keep them out of
the next extraction.
Hope it helps you!
-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED]
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/delphi-en/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/