algorithm - How to Implement 'Lucky Draw' functionality in C#? -


I am working in an e-commerce website (asp.net and c #) where I apply the 'lucky' The process of controlling will be as follows: - Users will have to buy a particular product in one day and I have to select the user who bought that product as a key draw winner for the day.

On the implementation of a lucky draw, my initial idea was to use random tasks provided by C #. And many thoughts have come in my thoughts ..

  1. How will this be effective if I only use random things in C #, would it be better if I had any Also implement random number generation algorithms?
  2. Is there an algorithm available for random selection? A group? I am open to your valuable comments and suggestions.

    Thanks / Alex

  3. The standard .NET library is sufficient for statistical processing. If you think you need a strong version, then use the standard library with .NET. Until you find thousands of buyers every day, I do not think you really need the crypto version. The algorithms themselves apply Do not do one reason that people use standardized random libraries, because it has already tested against statistical requirement for randomness Oh .. if you need to choose many lucky customers with the same likelihood, then only create one list, generate 0 and an integer between list length. Integer you get The first lucky customer stores it somewhere, remove it from the list, rinse and repeat for the next lucky customer. If you need to give a high likelihood according to their purchase calculation, then store the purchase details instead of the customer within the list. If you need custom weight according to the purchase price, use it, in which you give all the purchase prices for the day, then give each customer a cumulative value from their purchase. For example, if a sale of $ 350 is sold on that day, then the first customer to purchase the first 75 dollars has been 75, the second customer receives an acquisition of $ 9 (75 + 20), the third customer Received 10 dollars 105 (95 + 10), etc. Choose a random integer between 0 and total sales, and the lucky winner is the customer who is the lowest value that is still higher than the resulting integer. Remove the winner (both their total and the position), rinse and repeat before the list.

Comments