Answer the question
In order to leave comments, you need to log in
What lottery winner selection algorithm to use?
given there is a lottery
each participant receives n number of lottery tickets from 100 pieces
, the more donations, the more tickets.
how to choose the best winner in this case?
Answer the question
In order to leave comments, you need to log in
to assign to each participant a number equal to ti = ni/(n1+n2+...+nk) ni - the number of tickets of the i-th participant. k is the number of participants. choose a random number from 0 to 1 - let it be p. then we divide the segment [0,1] into intervals [ti-1,ti). Whatever p hit, that participant won. Next, randomly select a ticket from his tickets
take a very large number obtained by hardware (32 times tossed a coin - tails 0 heads 1 - translate in the calculator from binary to a more understandable calculus)
look for the remainder of dividing by the number of tickets +1 and get the number of the winning ticket
if your tickets are not numbered, then number them - make a list of participants, multiply the participant's serial number by the number of tickets and add them to the accumulator if the number in the accumulator is less than the number of the winning ticket, then the participant did not win and so on until the first winner
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question