Cycling has taken a backseat for the past couple of months. Exercising for my back, and waiting for it to heal are more important.
Life without some activities can get boring. So I am participating in Google's online coding competition, CodeJam. For those of you in the know, the qualifying round is already over. 8523 qualified for the next round, including me. 10492 participants had a crack at the problems.
This is perhaps the first time that I am participating in a competition I do not expect to win. Earlier I have avoided competing in certain competitions fearing failure! So this is a big improvement for me - and it took me some effort to force myself into this. Advancing to the next round would be good for now.
I am embarrassed to find myself placed in the 5839th position. I got 43 points - 33 for problem A and 10 for problem C. I knew I hadn't been solving problems of late, and this is just an additional confirmation. My score shows me how negligent I have become. A very bad mistake cost me 23 points for problem C-large. I had to use a 64 bit integer to avoid a numeric overflow. But I overlooked such a simple thing! Problem B, "Fair warning", was IMO the most difficult of the three problems. For some strange reason, I didn't write a single line of code for this. Naturally, I missed out solving this.
By now you are perhaps wondering why I should be ranting about this, and that too in public. Most of you guys are here for articles related to cycling. However, I consider myself a geek first ! And for a geek to realize that he has gone bad w.r.t. coding can be very bad indeed. Many of my readers are from the IT industry, so I am hoping this rant is is relevant to at-least some of you.
I was not always like bad. I (and others too ) counted myself a very good programmer. I was careful, would pay attention to details and perhaps made much less mistakes. I could also work through problems. Clearly not the case now. Over the years, what one needs to do changes. Most of our time gets spent on integrating pieces of software - and we write only bits of software that we need. That effectively sends the algorithmic muscles to sleep. Ah ! The only way to get back in shape seems to be by practise. And that's what I need to do to get through the next round. Note that I'm not saying the solving small, well-defined problems is more important than solving larger real world problems. They are perhaps different kinds of skills, but each needs to be exercised to grow to your potential !
I learnt a few things in the first round. Sharing these in the hope that they would be useful.
- Work out problems on paper. It's easier to see patterns there.
- Enable compiler optimization. I use -O3 with GCC. That cut down the runtime of one of the programs from 2 minutes to 30 seconds. Every second counts in competitions. Waiting for problems to finish executing can be frustrating during competitions!
- Have a nice workflow ready. Compete directly from your development machine and avoid copying around files from one machine to another. This can lead to costly mistakes. I saw a colleague make this mistake, so sharing it
- Use a good system to compile code. I use SCons
Good luck to myself for the next round ! Normally I wouldn't believe in luck. But when skill levels go low, we all start believing in it, eh