Hourly prize instant giveaway algorithm

拥有回忆 提交于 2019-12-13 05:22:50

问题


I've been asked to build a prize giveaway web page with the following competition parameters:

  • A user can only enter the competition once per day
  • It's an instant win competition, the user will know if they have won or not when they enter
  • We want to give away on average 1 prize per hour

My first thought was at the start of each hour, to select a random second within that hour for the prize to be given away. The first user who enters after that second is the winner. If a hour goes past where no one actually enters, a new time will be chosen somewhere in the next 12 hours to give away that hours prize (this is to stop the late night prizes all being given away in the morning).

I can't tell if this will be random enough for a fair competition. Also, there is a slight security risk in that if someone were to view the upcoming prize draw database record, they could enter at the right time and win the prize.

Is there a better way to achieve this?

来源:https://stackoverflow.com/questions/26826287/hourly-prize-instant-giveaway-algorithm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!