Settings

Theme

Verifiable random choice (contest winner) algorithm

3 points by gliderShip 10 years ago · 2 comments · 1 min read


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?

crispy2000 10 years ago

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.

tylfin 10 years ago

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]```

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection