Hacker News new | ask | show | jobs
Verifiable random choice (contest winner) algorithm
3 points by gliderShip 3814 days ago
Hi guys, i need to pick a random winner for a contest from a list of phone numbers. Could somebody suggest a verifiable random algorithm. Something on the lines of "Pick the winner based on the daily national lottery numbers". Does anybody know a free api endpoint for lottery numbers?
2 comments

You could also look at the Bitcoin blockchain, e.g. on the blockchain.info web site. There is a new block generated every 10 minutes or so. Some useful fields in the block include the nonce (a 32-bit unsigned) or the block hash. You can set a target time and say that the first block generated on x-date (UTC) will be used. Blockchain.info and some others like it have a free API.
One way: write a simple python script, ```import random phone_numbers = [] with open('list_of_phone_numbers.txt', 'r+') as file: for phone_number in file: phone_numbers.append(phone_number)

random_pick = random.randint(0, len(phone_numbers)-1) print phone_numbers[random_pick]```