Skip to content

Instantly share code, notes, and snippets.

@Arachnid
Created January 28, 2017 08:20
Show Gist options
  • Save Arachnid/0585ae8840572f75b11ae4fc5ad057a1 to your computer and use it in GitHub Desktop.
Save Arachnid/0585ae8840572f75b11ae4fc5ad057a1 to your computer and use it in GitHub Desktop.
import random
donors = [
(0.009559, '0x1cb9e58e03b3365434a863935e8b92a178bb9d60'),
(0.8, '0x23ee0a4332be289c39a92b3324043f06973edbb9'),
(11.0, '0x6162b1e823644580f06cefd5aa51c65b5bb56f2e'),
(2, '0x831cffd303252765ba1fe15038c354d12cebabd1'),
(2.362, '0xdd289578d8915156de085df3d03062335238a293'),
(2.386913, '0xb9b79944fad2956413a8979fc05d39464f1d5249'),
(1.0, '0x82eae6c30ed9606e2b389ae65395648748c6a17f'),
(50.0, '0xe10c540088113fa6ec00b4b2c8824f8796e96ec4'),
(66.0, '0xd1b39607285d6b8497c3ec3e1b0138c3a34c2d4a'),
(0.12986353, '0x0b0dcbd0cc60e9dcdf85d565791aafa8f0d7b1dc'),
(200.0, '0xa0510da4eea8247135a6cabbf5f5e7f39275393c'),
]
total = sum(donor[0] for donor in donors)
prizes = [
"Atlas Reactor - All Freelancers Edition",
"Down and Out in Purgatory",
"How Real Men Do It",
"Mad City",
"Double Play",
"Deadfall",
"Now We Are Sick",
"Telling Tales",
"Magic Origins Deck Builder's Toolkit",
"Pairs: Lord of the Fries",
"RIFT Starfall Prophecy - Standard Edition",
"The End of the World RPG: Wrath of the Gods",
"Van Helsing",
"YEARS BEST DARK FANTASY & HORROR 2011"
]
blockhash = 'e98123672cbeefbf10d9bba47ecfced90620d87ba3c8e269611e88155600edb6'.decode('hex')
rand = random.Random(blockhash)
for prize in prizes:
value = rand.uniform(0, total)
for donor_amount, donor_address in donors:
if value <= donor_amount:
print "%s wins %s" % (donor_address, prize)
break
value -= donor_amount
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment