For the last few days, I've been busily coding away at USACO. For those who don't know, it's a place where they train you to do algorithmic programming of the kind that you see at TopCoder and so forth.
They follow a pretty effective technique of dividing their training pages into sections of increasing difficulty. As you finish solving one section, the next one becomes accessible. In about 4 days(I'm not very certain), I've done sections 2.3, 2.4, 2.5 and 3.1, which amounts to about 15 problems. That rate is almost devastating enough to be scary, because I've never coded so fast before. This leads me to conclude that I'm channeling the departed spirit of Edsger Dijkstra...
At any rate, I seem to have achieved what Mihaly Csikszentmihalyi(quite a mouthful, isn't it?) calls flow - a weird sort of state where I lose myself in code and algorithms, time ceases to have any meaning and my productivity increases tenfold. Like Csikszentmihalyi says in his books, it's an incredibly fulfilling state of mind. I'm tempted to say that there's this undercurrent of joy which pervades my being, but that isn't exactly it - it's more like nothing else in the universe matters other than the problem I'm working on and the act of solving it. It's a bit like being in a dream state, where things keep on happening all around you, but you don't seem to care very much, because all your attention is focused on just one thing.
If you haven't figured it out yet, I'm going to be chattering merrily on this subject for the remainder of this post. It's not particularly technical, though the stuff that I was doing was technical. I'll mostly talk about what it felt like. That should be enough to satisfy the people who like that human-interest stuff(as if writing code weren't a uniquely human activity!).
Interestingly enough, as I write this, I'm also chatting with Sagar, trying to explain the logic for a certain problem I was doing last night. The problem is section 2.5's Stringsobits, if anyone wants to know. I gave him the problem statement last night, and he got pretty interested(Sag, good to know the engineer in you still lives!). He tried a brute force algorithm, but of course, the constraints wouldn't allow that, otherwise I would have pulled it off in about 3 minutes...
I figured it out at around 2:30 AM last night. I was practically possessed - I had to solve that problem, and I was on the verge of seeing the pattern for so long that I knew I wouldn't be able to sleep until I had it. When I did see it, I was practically on cloud nine - I would have jumped up and down for joy if it wouldn't have woken people up...Frankly, it was the only problem in section 2.5 that I really found hard, and I wound up that section this morning with the last one I had left(Prime Cryptarithm), which turned out to be incredibly simple.
One of the things that used to happen to me earlier(like about a week ago), was that when I wrote code to solve a particular problem, I couldn't bring myself to like all of it equally. I'm not sure 'like' is the word I want, but it's the closest I can get. There's the stuff that really solves the problem, and the other stuff that's just helping out - I/O, formatting, parsing and all that. During the last few days, that distinction just went away. I became indifferent to the code I wrote, in a sense. Amazingly, the quality of my code skyrocketed, and I got more things right the first time than before. I can look back at my code now and love its elegance, but when I wrote it, I didn't have the same kind of emotional response I used to have. The feeling was a sort of 'smoothness' - the kind of feeling you might get on a boat cutting through the water, with wind ruffling your hair, and no troubles on your mind. In other words, my mind was flowing. No resistance - just ceaseless motion.
And if any fellow computer engineers think that writing code doesn't elicit an emotional response, I recommend they rethink their choice of career.
I've finally decided to stop and relax for a bit. Might as well enjoy this nice feeling of fulfillment in this excellent weather. This is what relaxation should feel like.
For all those people out there who talk about having a sense of proportion, here's a bit of advice - Don't. It's all very well for the little things that don't matter much to you, but for the work that you really care about, throw out any smidgen of an iota of a scintilla of a suggestion of a limit. There ain't no such thing.
In an interesting coincidence, while I was musing about having a sense of proportion, who should come along but Paul Graham, with another masterful essay on procrastination. Relates well to my thoughts on the subject.
PS: I'm not sure if I mentioned this before, but the pigeon nesting outside the kitchen window finally hatched her egg. Junior has grown incredibly fast. He's now at the point where his parents can't sit on him any longer - something they spent an inordinate amount of time doing earlier. I still haven't made up my mind whether they were protecting him from the cold or if they were just too dumb to figure out that you don't sit on the chap that comes out of the egg...
Wednesday, December 28, 2005
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment