John Fremlin's blog: Crashing out of the Codejam 2009

Posted 2009-09-27 06:20:00 GMT

I entered the Codejam 2009. Last night I flunked out in round 2. You can see my awful solutions to earlier problems.

It isn't easy to talk about doing something badly, and I certainly did the Code Jam badly. But I'm going to do it because I don't want to hide from it. If you want an up-beat post, this isn't it.

Last night I couldn't even get out the easy five pointer (small problem D) because of an idiotic mistake in the logic when there were two instead of three plants. I got into an awful state of stressed, exhausted confusion. The contest was from 1 AM to 3:30 AM local time, and the last round I tried to play at this time (round 1B), I also had two solutions that seemed to me to be right but which were wrong because of logic errors tangential to the main argument. (I ended up rushing back from hiking the next day to do round 1C in McDonald's, and quiting it early to go to the bar after two problems; to my horror one of the big solutions was actually incorrect, so I only just squeaked in to round 2.) It would be convenient to blame my poor showing on it being late at night, and me being stressed out from arriving in a new city. But the real reason lies in my approach to solving problems.

In all three rounds I played (1B, 1C and 2) I had almost-working solutions that were not correct. I was unable to find the problems in some cases, and in others was unable to correct them. I did not go through test cases in a considered way; nor did I successfully review my code. My approach was to panic.

Writing incorrect code is possibly worse than not writing code, because finding a problem in code that works in the majority of cases is very time consuming. The fact that I wrote so much incorrect code is a huge wake-up call. Ever since I converted my sound driver in the Linux kernel to use ISAPNP, and had it compile and work first time, I have prided myself on writing correct code.

That was ten years ago, and apparently — not so much anymore. It seems that when dealing with well-specified problems of small complexity I make a huge number of basic errors. Perhaps simply I have not been sufficiently testing the rubbish spewing out of my keyboard.

Time for some automated tests and a gander at sb-cover, methinks. This was my first Codejam and I will have to raise my game for next year.

anonymous is watching for you

Posted 2009-09-28 10:32:48 GMT by Anonymous

Post a comment