Sunday, July 29, 2012

Win the lottery with Ruby

My Mom plays the local "Pick 5" game regularly. Whenever she has a few bucks to spare, she'll have me get her a few tickets, and I'll always do the 'quick pick' and let the computer generate the ticket for me. I never had a 'system' to pick numbers like some people do (special dates, numbers, etc.) so I figured that 'quick picks' were as good as anything.

I decided to get a little scientific with this stuff. I created a csv file with the results of the past 60 drawings, and formulated a little ruby script to tell me the occurrence of each number sorted by frequency.

I just bought her three tickets using my 'system': 1 ticket with the five numbers with the overall highest frequency. Looking at the frequency breakdown, there were more numbers that appeared 9 times than any other frequency, so I bought two more tickets, one using 5 of those numbers, and one using the other 4 that occurred 9 times, and one that occurred 8 times.

 The most she's ever 'won' before was $5, so we'll see if my system pays off any better for her :)

Here is the script if you are interested:


  1. yes, but if you flip a coin 49 times in a row, and each time it comes up tails, the odds are still 50/50 that the next time it will come up tails again.

  2. I hope I can win a big lottery jackpot like that someday. I've been spending a lot of time studying patterns and mathematical probabilities, and I think it's entirely possible. I won $10,000 once using a system I found online (here's a review if you're interested: ) If you keep playing smart and not just picking completely random numbers, you'll win eventually.