@patrickikis
  @patrickikis
patrickikis | Why you shouldn't play the lottery - A python code simulation (code included) @patrickikis | Uploaded 2 years ago | Updated 5 hours ago
Here is my code. I'm sure that it can be improved upon. Sorry for the lack of commenting. I rarely comment my code, and only do it when I have to =)


from random import randint
import time
import datetime
mylist = [3,15,18,22,37,46]
one = randint(1,60)
randomlist = [0,0,0,0,0,0]
state = 0
counter = 0
x = 0
newtime = 0
enddate = 0
starttime = time.perf_counter()
startdate = datetime.datetime.now().strftime('%m-%d-%Y_%H.%M.%S')

def getNum():
global state
global x
state2 = 0
global randomlist
while state == 0:
x = randint(1,49)
for i in range(5):
if ((x != randomlist[0]) and (x != randomlist[1]) and (x != randomlist[3]) and (x != randomlist[4]) and (x != randomlist[5])):
state2 = 1
return x

while state == 0:
randomlist[0] = getNum()
randomlist[1] = getNum()
randomlist[2] = getNum()
randomlist[3] = getNum()
randomlist[4] = getNum()
randomlist[5] = getNum()
randomlist.sort()
#print(randomlist)
counter = counter + 1
if randomlist[0] == mylist[0]:
if randomlist[1] == mylist[1]:
if randomlist[2] == mylist[2]:
if randomlist[3] == mylist[3]:
if randomlist[4] == mylist[4]:
if randomlist[5] == mylist[5]:
state = 1
newtime = time.perf_counter()
enddate = datetime.datetime.now().strftime('%m-%d-%Y_%H.%M.%S')
print("Done")
print("My Fixed Numbers = ",mylist)
print("Last Draw Numbers = ",randomlist)
print("Total Draws = ",counter)
dollars = counter * 2
print("At two dollars a ticket, you've spent: $",dollars)
timeyears = counter / 104.286 #Two draws a week
print("It took ",timeyears," years to hit your numbers at two draws a week")
sum = float(newtime) - float(starttime)
print("Program Runtime = ", sum, "Seconds")
print("Start Date = ",startdate)
print("End Date = ",enddate)
samples_per_second = counter / sum
print("Samples Per Second = ",samples_per_second)
Why you shouldnt play the lottery - A python code simulation (code included)Arduino Epoch Project#7: The Light Sensor and the RelayHaving fun with 25x 400F 2 7v Super Capacitors!  Just for fun!The IR XY Linear Actuator Driver and Electromagnetic Lock Controller Set!The ES6937 Motion Sensing Swivel Disc for Arduino - Putting it all together!

Why you shouldn't play the lottery - A python code simulation (code included) @patrickikis

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER