Pages:
Author

Topic: Bitcoin Lottery: minimum just 0.01 btc! Next draw: July 1 Jackpot 1.52 btc - page 4. (Read 10978 times)

newbie
Activity: 28
Merit: 0
I sent you the 0.02 coin!
E
full member
Activity: 234
Merit: 100
newbie
Activity: 25
Merit: 0
Eh I guess it's worth a shot. Something to spend my free bitcoins I got on.
newbie
Activity: 28
Merit: 0
The first 6 participants will get 0.02 bitcoin. So when you enter with 0.01 bitcoin you earn 0.01 and can also win the lottery!
newbie
Activity: 28
Merit: 0
Note: this lottery is just for fun, I don't want to earn any money with it.
newbie
Activity: 28
Merit: 0
What is the Bitcoin Lottery?

The Bitcoin Lottery is a lottery where anyone can win, the lottery takes no share and the process is transparent. The code that picks the winner(s) is open source.

How does it work?
You can send an arbitrary amount of bitcoins (minimum 0.01 bitcoin) to an adress. The adress for next lottery (closes July 1) is:

Quote
1LUeahDNnVwqh8utERNxPhoh7zdzSmh4AG
(view: http://blockexplorer.com/address/1LUeahDNnVwqh8utERNxPhoh7zdzSmh4AG)

When do I win and how much?
All bets are randomly assigned to a block. Each block is equal to the average deposit. The program picks randomly a block and returns the winners and their share (in percent).
For example, if you send 0.1 bitcoin and the average is 1 bitcoin, you probably end up in one block and then you win 10% of the draw.
If you send 1 bitcoin and the average is 1 bitcoin, you probably end up in two blocks randomly, for example 10 cents in one block and 90 cents in another. If you win with the first block you win 10%, the second block will return 90% of the draw. So to be sure to have the chance of winning 100% you need 2 bitcoins.
The program is designed in such a way the lottery will always return 100% of the jackpot size.

Don't you cheat?
No. The first and second block on 1 July (after 0:00 UTC) will be used as random strings by adding them and create a SHA256 hash.

The code (Python)
Code:
import math
tickets = [
    ["1Km4sASEeKUWPtjRaSxmVghF5FfkadWVei",2],
    ["18uZGH42pcmHVtZ8sux7bCf8oJJtSCAAJs",1],
    ["1Jmn97kfJ6DBBCuft6Z1oW8e2Lwgheyr6s",2],
    ["1Jmn97kfJ6DBBCuft6Z1oW8e2Lwgheyr6s",1],
    ["1Jmn97kfJ6DBBCuft6Z1oW8e2Lwgheyr6s",1],
    ]

class BitcoinLottery:
    def __init__(self):
        self.total = 0
        for x in tickets:
            self.total += x[1]
        self.BLOCKSIZE = int(math.ceil(self.total/float(len(tickets))))

    def shuffle(self, rand):
        i = 0
        prevx = 0
        for t in range(len(tickets)):
           j=0
           shuffle=0
           for x in range(t, len(rand)):
               j = j + ord(rand[x])
           shuffle = j % len(tickets) - i          
           tickets[i], tickets[i+shuffle] = tickets[i+shuffle], tickets[i]
           if (i < len(rand)-1):
               i+=1
           else:
               i=0  
   
    def calculate(self):
        blocks = []
        block=0
        for x in tickets:
            k = x[0]
            v = x[1]
            nblock=block
            while(v>0):
                r = self.BLOCKSIZE - block % self.BLOCKSIZE
                if (v <= r):
                    a = v
                    nblock+=v
                    v = 0
                else:
                    a = r
                    v -= r
                    nblock += r
                blocks.append([int(block/self.BLOCKSIZE),k,a])
                block = nblock
        rand = 0
        print("total: " + str(float(self.total)/100) + " bitcoins")
        for x in blocks:
            if (x[0] == rand):
                print(x[1] + " won " + str(float(x[2]*self.total)/10000 * (100/self.BLOCKSIZE)) + " bitcoins")
bit = BitcoinLottery()
bit.shuffle('3029309209i1');
bit.calculate()
Pages:
Jump to: