Last active
October 27, 2019 12:56
-
-
Save angeloped/84b171433160318bb55968acf1f17a49 to your computer and use it in GitHub Desktop.
lotto lucky number guesser... (for PCSO Lotto only)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment