/    Sign up×
Community /Pin to ProfileBookmark

Giving Away Tshirts Over Fixed Time

Hey guys, I’m trying to tackle a project and I’m not positive the best way to go about it.

I have a contest entry program where users register for a grand prize, but also have a chance to win a free t-shirt instantly. I’m currently giving away shirts based on a flat percentage, but I’ve been asked to give away a certain amount of shirts in a given time period.

100 shirts for the first 5 hours
then 200 shirts for 7 hours after that, and 200 more for the 7 hours after that.

I’m not looking for code examples, just concept recommendations.

Thanks.

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@GUIRNov 17.2009 — you may use timestamps, additions to timestamps and random (rand()) selections..
Copy linkTweet thisAlerts:
@jelatinauthorNov 17.2009 — I plan on using all of those things.

Maybe I should have been a little more specific.

I'm unclear as to how to construct a mechanism that will allow for a relatively even distribution of these shirts over time.

So if the program only has 20 shirts for the last hour, it can adjust the win % accordingly to allow for as even a distribution as possible.
Copy linkTweet thisAlerts:
@criterion9Nov 17.2009 — You could find the remaining time between now() and your end date. Then take the total number of tshirts remaining for the period and divide that by your remaining time. That gives you your percentage chance of winning the Tshirt.
Copy linkTweet thisAlerts:
@NogDogNov 17.2009 — You could find the remaining time between now() and your end date. Then take the total number of tshirts remaining for the period and divide that by your remaining time. That gives you your percentage chance of winning the Tshirt.[/QUOTE]

I was thinking of either something along that line, or if you want to make it deterministic instead of stochastic, you could calculate how many shirts should have been given away by the current time, and if the actual number is less than that, then the current request wins.
×

Success!

Help @jelatin spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...