Loteria Nacional

Last week I was asked to help out with a quick Perl script for the Dominican Republic Lottery.

Unlike in the States and Europe, the Loteria Nacional is a semi-privatised affair. The sales of tickets and awarding of prizes is open to any private company that registers with the government. The government picks the actual numbers every night on TV at 8pm. And collects taxes from those companies. Interesting way to distribute the problem. The government insures some legitimacy to picking the numbers (rather than leaving open all kinds of abuse with completely private illegal Numbers Games) and gets some income (which goes who knows where, but whatever) all without having to organize anything substantial (extra big bonus here), like setting up a secure network of lottery purchase machines. So besides the actual sellers, there’s a cottage industry of companies selling computing systems to sell lottery tickets.

The loteria is typically three numbers. You can win something by even hitting one number. Any small or large amount can be gambled, to appeal to the dreams of the many poor here. As a result, the more sophisticated lottery systems allow the merchant to monitor which numbers are being picked in real time. If one number is being oversubscribed, he can stop sales on that one number. Too many 33s this afternoon, block 33 and sorry, you can have 32 if you like, thanks.

One particular company installs linux machines at sales locations, and collects numbers and determines prizes on a central server. All in COBOL-85 of course. The telecommunication here being what it is (something to do with luck) the machine only phones home occasionally. And this opens up a potential abuse. After the numbers are announced at 8pm, someone on location disconnects the network and shuts down their linux box, resets the time in BIOS, and once the box has come up again buys some winning numbers in the past. Restart and reset the BIOS to the present time, and connect the network. Wow you won!

So the company has now installed queriable USB devices which only keep the current, unmodifiable time. And the Perl script I helped hack together .. simply compares the time on the linux box with the usb device, and if its off by more than a few seconds, it kills processes and complains loudly.

Hooray for Perl, making sure people lose their money fairly.

Comments are closed.

Comments