Thursday, October 22, 2009

How do you end an email exchange?

One unexpected (by me, at least) byproduct of our technological age is the never-ending email conversation. I'm not sure if it's the desire to have the last word, or simply the feeling that leaving someone hanging is rude, but some email conversations go on for days, weeks, even months after their actual content is depleted. (Many, of course, never had any actual content to begin with.)

When you're on the phone, you're talking in real time, which requires some amount of concentration. You can end a phone conversation because talking on the phone is a physical committment. Sure, you may have enough attention left over to cook, grimace with impatience, or drive into oncoming traffic. But for the most part, phone conversations will eventually end just from the sheer physical exhaustion of the participants.

Not so email. Because you can answer email at your leisure, and because each party assumes the other will eventually return to the computer, you can keep firing salvos of small talk to prop up an otherwise moribund conversation. "Thanks", "No problemo", "See you later", "You too", "Ok, bye", "Ciao", and so on. Of course, since most people repeat the entire previous exchange in each new message, the message size keeps growing and growing, even as the new content gets shorter and shorter.

Unbeknownst to many email users, most email messages contain a hidden message ID, and when you reply to a message, your reply contains a "references" header that lists the earlier message IDs in the conversation. These lists can just keep growing and growing as the conversation reaches maximum verbosity. Try this sometime. See if your email program lets you see the "original" message, and then look for a header at the top labeled "References:" I wonder if there's a Guiness world's record for longest reference list.

Friday, October 9, 2009

Bit Counting (The end, I hope)

So the original question was, "How do you write a function to count the number of bits set in an arbitrary byte?" I figured that if you're going to do this repeatedly, it might be worth just building a lookup table. The question then becomes "How do you populate a table of set bit counts for each possible byte?" This can be solved with a simple iteration:

int exp = 1;
table[0] = 0;
for (int i = 1; i < 256; i++)
{
if (i == exp*2) exp *= 2;
table[i] = table[i-exp] + 1;
}

Now if I had thought of that during the interview ...

Thursday, October 1, 2009

Things to hate

  1. People who insist on adding milk and sugar to their coffee while it's sitting under the coffee maker, so that my mug gets covered with the milk and sugar they've spilled.
  2. Coffee makers in general, for that matter.