# Algorithm For Random Distribution of Prizes Over A Given Time Period

I have been assigned a task to come up with an algorithm for evenly distributing prizes over a given time frame, I am looking for advice as I am a bit stumped on where to start.

Here are my requirements:

Prize Types:

• Prize types are types of prizes which can be added by a user, there can be any number of prize types
• A prize type should last for a set period of time i.e 30 days
• A prize type has a limited quantity i.e 10

Scope: When a user signs on to our site, they have the opportunity to win a prize. You need to distribute prizes throughout the course of the time period randomly in a way that ensures the prizes never run out 3 days before the end period ends.

My Thoughts: I understand that I will need to factor in prize quantity over the time remaining from the initial period at the point in time a user registers, and generate a probability from these figures but I am stuck on finding a reliable way to do this that keeps the distribution random

Any suggestion appreciated

• If you have an estimate on the number of sign-ons $N$ until the end of the 30 days and have $k$ remaining prizes, then the probability that a sign-on wins a prize should be $k/N$. Once $k$ gets very small (say 1 or 2), you can make this probability zero until the last 3 days, and then continue as before. – Yuval Filmus Apr 6 at 9:21
• Thank you for your solution however the number of registrations is an unknown factor, the scope of the problem is being able to modify the probability based on the remaining days and the volume of prizes available – Thomas Clague Apr 6 at 13:25
• Choose $k$ random times (where $k$ is the number of prizes), at least one in the last 3 days. The first sign-on after each random time wins the prize. – Yuval Filmus Apr 6 at 15:04