Hello! I'm a web programmer and have been commissioned to develop a simple site that accepts a 'ticket number' and then tells the visitor instantly whether they have won a prize or not. What seemed originally like a simple problem has, under further thought, proven to be nothing of the sort and I need expert help.
The problem is largely that of ensuring that the prize allocation is fair, logical, and evenly distributed. This aim is complicated by the following factors: The competition is based upon physically received leaflets following a visit to a store. The competition will run for three months or thereabouts. The number of prizes is very small in comparison to the number of entries.
What all this means is that I cannot simply use a 'random number' device to decide upon a winner. Doing so presents a finite possibility that all the prizes will be won in the first week or that none are won at all. Neither can we limit prize winning based upon those already won (we can't say a prize has been won this week so no one can win now until at least Monday morning) as this would be demonstrably unfair.
My current thinking is that the best solution is to perform some kind of operation on all, or part, of the 'ticket code' (the structure of which is entirely up to me) such that there is a specific probability of winning for any ticket, which matches the number of prizes and the anticipated entrants. So, for example, if there are 10 prizes and 10,000 entrants, I want the operation to result in a probability of 1 in 1000 that this ticket is a winner. The operation must work on all ticket numbers so that every one has the same chance of winning and should preferably, be somewhat flexible such that if, as the competition progresses, it becomes obvious that we're not going to get 10,000 entrants but only 6,000, or 20,000, that the odds will automatically alter.
To introduce a truly 'random' element into the selection process I'm considering using the time of entry as part of the operation.
Although I've got this far in the thought, I'm afraid the actual math is beyond me - I think. Can anyone help with what I should be doing here, or suggest an alternative approach? My need has become rather urgent as the customer is itching to start printing the leaflets and I haven't got a code structure to give them yet!
Jon