Going with a Python script QP for the power ball tonight...

Published:

Updated:

I have not updated power ball (or mega) histories since last year... that is a project for another day.

But, it is a bigger jackpot so I have a short script to generate a QP (using all possible numbers) that will be getting a run tonight.

Going to use sorted(random.sample(range(1,70),5)) for the white balls and random.randint(1, 26) for the red ball.

Note how range(1,70) will exclude the top of the range,.. so picking from 69 numbers requires the 70 at the top, BUT randint() picks between the range bottom and top, inclusive. Gotta love the strange python stuff...

My wife wants a machine generated QP, so there is a bit of a competition potential...

Entry #471

Comments

Avatar hypersoniq -
#1
For any Python fans playing along...

import random

white_balls = sorted(random.sample(range(1, 70), 5))
red_ball = random.randint(1, 26)
print(f" The WINNING white balls are: {white_balls}")
print(f" The WINNING red ball is : {red_ball}")


Nothing wrong with a little positivity...
Avatar JADELottery -
#2
An EXCEL Function we use.


Function RandComb(ByVal n As Integer, ByVal r As Integer) As String
    Dim vs As Integer 'Value Selection
    Dim v(9999) As Integer 'Values Array
    Dim s(9999) As Boolean 'Sorted Selected Values Array
   
    Dim textformat As String
    For a = 1 To Int(Log(n) / Log(10)) + 1
      textformat = textformat + "0"
    Next a
    textformat = textformat + " "
   
    Dim temp As String 'Temporary String Storeage
    temp = "" 'Initialize Temporary String
   
    'Initialize Arrays
    For a = 0 To 9999
        v(a) = a
        s(a) = False
    Next
   
    'Select R of N values
    For a = 1 To r
        vs = Int(Rnd * (n - a + 1)) + 1 'Randomly select a value from 1 to N of any remaining values less by previous selections
        s(v(vs)) = True 'Set sorted select value array


        'Shift to lower array positions those values greater than the current randomly selected value
        For b = 1 To n - a
            If b >= vs Then
                v(b) = v(b + 1)
            End If
        Next
    Next
   
    'Add in order the selected values
    For a = 1 To 9999
        If (s(a)) Then temp = temp + Format(a, textformat)
    Next
   
    'Return the selected R of N values
    RandComb = temp

End Function
Avatar hypersoniq -
#3
This would be VBA (Visual Basic for Applications)?
Thanks, that is an interesting function.
I hear Microsoft is beta testing full Python embedded in apps like excel... that would be a dream come true !
Avatar hypersoniq -
#4
And the results were as expected, zero numbers matched in the white balls or the powerball. 2+1 on the double draw though... cost $4, win $20, net profit $16

Post a Comment

Please Log In

To use this feature you must be logged into your Lottery Post account.

Not a member yet?

If you don't yet have a Lottery Post account, it's simple and free to create one! Just tap the Register button and after a quick process you'll be part of our lottery community.

Register