TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Verifiable random choice (contest winner) algorithm

3 点作者 gliderShip超过 9 年前
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 条评论

crispy2000超过 9 年前
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超过 9 年前
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]```