Just like any other organ, your brain needs exercise. If your daily job includes boring “business stuff” where most of the time you struggle with the integration problems and not with the actual problem domain issues, you are most likely not occupying your brain enough. If you want to stay in shape you need to practice.
There are several sites where you can find lots of small problems to solve. I have recently started following the Ruby Quiz and find it quite interesting - each week a relatively small problem is posted; the language of choice is Ruby and there’s no competition, people solve the problems for the fun of it. The best solutions are dissected and analysed so that all the participants can learn something.
One of the problems linked to the Code Golf, which is a slightly different take – challenges are issued less frequently and the goal is to create as short solution as possible. You can use several scripting languages: Perl, PHP, Python and Ruby. The solutions are not posted publicly because every challenge is a competition. There is a simple formula for calculating the score and the list with rankings is available either for a particular language or as an overall list.
Their latest problem involved some ASCII art (the result of the the first sample is on the screenshot to the left), the problem looked simple enough so I decided to give it a try. I chose Ruby as a language, even though the top 10 list for this particular problem was completely dominated by Perl solutions. After a couple of minutes I had a working solutions that was… about 180 characters long (whitespace included).
A quick look at the Ruby leaderboard was quite depressing – the best solution had only 71 character (!) and the 10th one was 82 characters long.
So I started trimming my solution. After a couple of hours (!) I was able to shrink it down to 104 characters, which puts me in the first 16 for Ruby and barely in the first 40 overall(±1 place).
If you need a shot of humility, this is it 
Be the first to rate this post
- Currently 0/5 Stars.
- 1
- 2
- 3
- 4
- 5