Learning in the lottery

Source: Internet
Author: User
Tags sha1

The "Mystery of the Handlers" annual raffle, the lottery algorithm is very interesting.

Lottery algorithm: One, two or three and meow will be extracted according to the following rules and algorithms:

    1. Select the first bitcoin block generated after 2016/11/01 11.00 am

    2. Order use the transactions contained in this block to determine all winners

    3. Method: Take out the first transaction hash such as Fc927205f394d537b17b9d0db45aa1388c63dfbf8be9c2b3e5c8dd6696f7cee7 string stitching total lottery number, for example, 119394 cards, Take SHA1 ("fc927205f394d537b17b9d0db45aa1388c63dfbf8be9c2b3e5c8dd6696f7cee7119394") and turn the result into an integer : 752844761200031861206594954675289876476750084715, and total lottery number 119394 modulo. The figure 57479 + starting number 1000000 = 1057479 The first winning number.

    4. Repeat the process until all the winners are drawn. If there is a duplicate number, skip it and remove a transaction Hash.

    5. If the current block has run out of all the transactions, and has not drawn enough winners, continue to use the next block, the method is unchanged.

    6. We will upload the lottery information to GitHub for you to view after all the tickets have been sent. In order to protect the privacy of users, we will remove personal information, upload format: Lottery number, release time, SHA1. This algorithm allows users to verify that their/and other friends ' lotteries conform to this rule.

    7. If the winner is not successfully contacted within 10 days, the original number +1 will be used instead as the new winner. So the analogy.

The lottery calculation code is open source,https://github.com/planetcoder/readerLottery

This code uses the randomness of Bitcoin to generate winning numbers for sweepstakes.

How to use:

    1. Select the Blockhash of a moment at https://blockexplorer.com (whichever moment is determined according to the lottery rules)
    2. Run the script./lotteryresult.py blockhash number Total Startnum

Parameter description:

    • Blockhash the Blockhash of a moment
    • Number total winners, such as 50
    • Total number of lottery tickets issued, e.g. 59391
    • Startnum Lottery Number start value, in order to look good lottery numbers, generally with a relatively large value as the beginning, we generally use 1000000

Example:

./lotteryResult.py 000000000000000003eaa089e640ea339a4f5c83721a607c1075d3443a834e84 50 59391 1000000result 0 is 1026155result 1 is 1055107result 2 is 1056394result 3 is 1010464result 4 is 1047703result 5 is 1033045......

The above number is the result of each winning

Learning in the lottery

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.