?

Log in

No account? Create an account
AlbertJayNock

The lottery wheel program

I have already finished it. I am truly amazed.

My original plan was to have a "wheel" object which used a 2-dimensional boolean array to construct the lottery plays. Then I realized this scheme would reuse pairs of numbers more than I thought it would.

For instance, if 1-2-3-4-5 was the first number in the wheel, the pairs <2,8> and <3,55> would still be unused. But if I constructed the next play using these two pairs, the pair <2,3> would be reused.

And I thought I was so damn clever. (How often do programmers say this?)

So I came up with an algorithm that just uses an array containing a permutation of the numbers 1 thru 59. It breaks it into groups of 5 consecutive numbers, and puts them into the wheel. I actually started the other algorithm off this way.

Then it forms tickets using ever 5th number, then every 6th number, then every 7th. This will give me 40 tickets. I just won't use the last one.

Even though I wrote the program in Java, it ended up being more like a FORTRAN program...a clever algorithm with no data structures fancier than a one dimensional array. Given that I'm 52 years old, that's OK with me. But I'm disappointed that the correct solution didn't really require objects. I wanted to go into battle!

I just need to make the output prettier and send it to a file instead of standard output. And then wait for the following formula

((money left in stake)/(#drawings remaining in year))*(jackpot value in 100's of millions of dollars)

to be equal to 39. That will  be the hard part.

Comments