Post
Topic
Board Bitcoin Discussion
Topic OP
🎅🎄 Lottery for fun on Christmas Day.🎄 🎅
by
tomasholler002
on 20/10/2024, 22:51:58 UTC
Hello everyone!

With the holiday season approaching, I thought I’d suggest a fun initiative for the community: a Bitcoin prize draw to be held during the Christmas period!

The idea is simple:

There will be 3 prizes awarded to the top 3 winners, who will be determined using the Bitcoin block hash selected during the Christmas period, as specified in the Python program written at the end of the post. Each participant will be assigned a number and can have a maximum of 2 tickets.


How it works:

Each user who wants to participate will need to contribute a symbolic amount (10 $, in Bitcoin) to a dedicated address.
Obviously, for transparency, I can’t hold the funds myself, but "users who have the most credits in the forum."
Therefore, I’m asking  to user legendary handle the funds, which will then be distributed to the winners.

How the draw will work:

Each participant will be associated with one or more numbers.
During the Christmas draw, the first 3 numbers will be determined using the Bitcoin block hash mined on Christmas day and time.
The first 3 numbers will assign the main prizes to the winners.
Prizes:
🏆 First prize: 55% of the funds collected (assigned to the number corresponding to the third number drawn)
🏅 Second prize: 30% of the funds collected (assigned to the number corresponding to the second number drawn)
🥉 Third prize: 15% of the funds collected (assigned to the number corresponding to the first number drawn)

Main issue:

We need to establish a precise method to extract the 3 winning numbers based on the block hash and the number of participants.
The goal of this initiative is to create a moment of sharing and fun for the community, with no other pretension than to wish each other happy holidays and celebrate together in a unique way. It’s kind of like the lottery we used to have at church with recycled toys 😄. I believe everything is legal and complies with the forum rules, but if there are any doubts, we can look into it further.

Code:
def draw_winners(block_hash, participants, num_winners=3):
    if len(participants) < num_winners:
        raise ValueError("Not enough participants for the number of winners.")
    
    winners = []
    
    for i in range(num_winners):
        # Take the last 6 characters, and additional ones if there are more winners
        hex_slice = block_hash[-(6 + i):len(block_hash) - i]
        # Convert the characters into a decimal number
        decimal = int(hex_slice, 16)
        # Find the winner by using the modulo with the number of participants
        index_number = decimal % len(participants)
        
        winner = participants[index_number]
        winners.append(winner)
        
        # Remove the winner to avoid duplicates
        participants.pop(index_number)
    
    return winners

# Input the block hash and the number of participants
block_hash = input("Enter the block hash (64 hex characters): ")
if len(block_hash) != 64 or not all(c in '0123456789abcdefABCDEF' for c in block_hash):
    raise ValueError("Invalid block hash. Please enter exactly 64 hexadecimal characters.")

num_participants = int(input("Enter the number of participants: "))

# Create a list of participants from 1 to num_participants
participants = list(range(1, num_participants + 1))

# Draw the winners
winners = draw_winners(block_hash, participants, 3)

# Print the winners
print("The winners are:", winners)

code written in Python for managing the draw