TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Verifiable random choice (contest winner) algorithm

3 pointsby gliderShipover 9 years 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

crispy2000over 9 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.
tylfinover 9 years ago
One way: write a simple python script, ```import random phone_numbers = [] with open(&#x27;list_of_phone_numbers.txt&#x27;, &#x27;r+&#x27;) as file: for phone_number in file: phone_numbers.append(phone_number)<p>random_pick = random.randint(0, len(phone_numbers)-1) print phone_numbers[random_pick]```