The company I used to work for, like so many, had a lottery pool for playing the MegaMillions lottery. A few years ago, I wrote a simple VB program that read a CSV file, which stored everyone’s “lucky numbers” (little evidence exists that these are, in fact at all lucky) and after you entered the latest draw, displayed a visual representation of the results (see right).
Now, I’ve never had much luck with the widget-style programming exercises. Things like the awful Northwind database examples in Microsoft Access, and countless recipe XML samples have always left me cold. So I decided that I needed to pick something that had some “use” even if it was something as mundane as matching numbers in a lottery. I figured that this would give me a reasonable target, it would cover some basic Rails concepts, and would remain interesting enough to go that extra mile in order to get it to work the way I wanted.
First up, I needed to poke around in the Interactive Ruby shell to get a handle on the text manipulation functions. Stuff like “split” and CSV handling, brush up on my RegExp, and other such things. It also gave me a chance to experiment with some of the lessons I learned through online tutorials. Once I’d played around a bit, I felt that I should shift to the Rails model and start designing.