Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import time
- from random import random
- from bisect import bisect
- def probdist_choice(choices):
- values, weights = zip(*choices)
- total = 0
- cum_weights = []
- for w in weights:
- total += w
- cum_weights.append(total)
- x = random() * total
- i = bisect(cum_weights, x)
- return values[i]
- summary_2009_2019 = [('01', 240), ('02', 233), ('03', 209), ('04', 228), ('05', 214), ('06', 225), ('07', 210), ('08', 196), ('09', 196), ('10', 224), ('11', 249), ('12', 204), ('13', 220), ('14', 200), ('15', 227), ('16', 223), ('17', 240), ('18', 199), ('19', 243), ('20', 216), ('21', 234), ('22', 215), ('23', 235), ('24', 217), ('25', 238), ('26', 235), ('27', 241), ('28', 227), ('29', 229), ('30', 220), ('31', 252), ('32', 220), ('33', 230), ('34', 229), ('35', 225), ('36', 193), ('37', 218), ('38', 221), ('39', 222), ('40', 201), ('41', 211), ('42', 207), ('43', 217), ('44', 223), ('45', 228)]
- lucky_draw = [] # youuuuur lucky drawwwwww
- while 1:
- while len(lucky_draw) <= 6:
- lucky_digit = probdist_choice(summary_2009_2019)
- if not lucky_digit in lucky_draw:
- # push your digit to lucky draw
- lucky_draw.append(lucky_digit)
- print("lucky draw found: " + "-".join(sorted(lucky_draw)))
- # clear lucky draw
- del lucky_draw[:]
- time.sleep(1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement