My $1.5B-USD PowerBall Picker

So today is a big day in the USA. It is not an holiday or anything like that. But is is still big.

Today, the PowerBall Lotto is expected to top $1.5Billion dollar jackpot. That is a lot of $. So like many others, I wade into the crazy frenzy and bought some tickets. But I decided to up it a bit.

Since I let a machine, or rather a computer algorithm pick my numbers when I got the tickets. Why not just come home and implemented some quick code that would pick number too.

From the PowerBall lotto site, on how to play. They said that they pick 5 numbers from a drum of 69 balls. And each ball is numbered. So that must be 1 to 69, since I don’t think they would include 0. Then there is a last 6th number that is from a drum of 26 balls.

Here is screenshot of my code and a run to pick 5 sets of numbers:

Screen Shot 2016-01-13 at 7.14.26 PM

And here is the rather “complex”┬ácode in the Groovy programming language:

// pick some number for PowerBall Lotto

// a line is 6 number, 5 numbers between 1-69 and the 6th between 1 and 26

class Line{
int[] numbers;

void draw(){
numbers = new int[6]
Random rand = new Random();

numbers[0] = rand.nextInt((69 – 1) + 1) + 1
numbers[1] = rand.nextInt((69 – 1) + 1) + 1
numbers[2] = rand.nextInt((69 – 1) + 1) + 1
numbers[3] = rand.nextInt((69 – 1) + 1) + 1
numbers[4] = rand.nextInt((69 – 1) + 1) + 1
numbers[5] = rand.nextInt((26 – 1) + 1) + 1
}

String toString(){
draw()
println numbers
}
}

def l = new Line()
println l
println l
println l
println l
println l

 

 

 

 

Leave a Reply