søndag den 1. juli 2007

Lottery numbers

Hey! Last payout from the danish lottery was a staggering 10 million some euro. I'd like to get a piece of that. So what can we do to improve our chances?

Well, we assume it's impossible to just pick the right numbers, so we'd had to calculate a bit on the chances of a random hit.

In the danish lottery there are 36 different numbers, put together in 10 lists of seven to complete one row and one shot at the big bucks. That equals to 36^7 different possibilities for a row and 36^7 / 10 for a chance on a single ticket. So we'd have to buy 8 million tickets and assemble the orders to make sure there are no duplicates. That would cost 40 million euro's, not counting the hours of work filling in the tickets.

1 way of increasing our chances would be to know all drawn numbers so far and work on a kind of probablity. So what I did was find a way getting all 17 years worth of numbers out of the national lottery's webpage.

I went to the list of draws here: http://www.danskespil.dk/spil/lotto/indhold/resultater.php
But I found it only shows the last 2 years worth. I examined the html and found that an attribute was set to a draw for retrieving your selection. So I put it on the request like this: ?draw=1. I now have access to the last 17 years worth of numbers, so far so good.

I don't want to sit and retrieve all the numbers manually so I had to conjure a script for it. I would've used Python, but I don't know the framework well enough yet, so I ended up using Java. And ofcourse I started of by writing a test:

public void TestSingleExtract() throws Exception{
LottoDataExtractor lde = new LottoDataExtractor();
String numbers888 = lde.extract(888);

assertEquals("01 - 03 - 12 - 15 - 18 - 22 - 31:08",

String numbers1 = lde.extract(1);

assertEquals("04 - 06 - 10 - 14 - 17 - 22 - 33:02 - 21",

String numbers127 = lde.extract(127);

assertEquals("02 - 04 - 10 - 13 - 15 - 16 - 26:11 - 17 - 35",

In the above code I test on the extraction of numbers far between because I found out the html shifted a little in characters and the first version of my LottoDataExtractor simple counted characters. So I had to smarten up the program a bit by looking at tags instead.

I now have the lottery numbers from 17 years back. I will have to analyze these a bit, to hopefully find a trend or something, but I don't expect it to give me an immense advantage.

get the neatly formatted numbers here. Note, the last line is draw 889, which is 30/06/07, every line is a new draw.