On programming: Bugs

In the previous post I said 6 yes/no questions would suffice to identify one of the 52 cards in a deck of cards, and outlined an answer based on the deck having four suits, each with 13 cards.

But I was assuming you were holding a “standard” set of playing cards. My first question should have been, “Is this a pinochle deck?”

A pinochle deck has 52 cards in four suits. But there are duplicate cards. Only the 9, 10, jack, queen, king and ace are used. That gives four suits with 6 kinds, or ranks, of cards in each. It takes 2 questions for the suit, 3 for the rank, for a total of 5 questions.

In discussing the card-identification problem we have moved from mathematics to the world of programming. The process I described above for identifying the cards is called an algorithm. To program is largely to design and implement algorithms.

And as noted there is a fault in the algorithm I gave. There’s even a special word used by programmers to describe this: bug.

The origin of the term dates to Thomas Alva Edison, the famous inventor. The cited Wikipedia article includes the following quote from Edison:

Software bug

It has been just so in all of my inventions. The first step is an intuition, and comes with a burst, then difficulties arise—this thing gives out and [it is] then that “Bugs”—as such little faults and difficulties are called—show themselves and months of intense watching, study and labor are requisite before commercial success or failure is certainly reached.

I first learned of the assocation between Mr. Edison and “bug” back in the early 1970’s when the Supplement to the Oxford English Dictionary came out. I just tried to find the definition, only to learn you have to pay the OED folks $300/year for an individual account. However, I committed most of the reference to memory when I first read it, as it is such a charming story. As best as I can recall the first written use of “bug” in the sense we are using it here was in the Pall-Mall Gazette:

Mr. Edson, I was informed, was up late the previous night looking for a “bug” in his phonograph, an expression for a difficulty implying that some insect has secreted itself inside and is the cause of the difficulty.

Bugs are the bane of programmers. The good news for WordPress bloggers is that I haven’t run across many in my months of using WordPress, though I think I found one recently. Actually it’s more a design flaw than a bug. I posed a puzzler about it a few posts back. I’m still hoping the WordPress folks take a crack at guessing what it is.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

  • Pages

  • November 2006
    M T W T F S S
     12345
    6789101112
    13141516171819
    20212223242526
    27282930  
  • RSS The Wayward Word Press

  • Recent Comments

    daveshields on SPITBOL for OSX is now av…
    Russ Urquhart on SPITBOL for OSX is now av…
    Sahana’s Respo… on A brief history of Sahana by S…
    Sahana’s Respo… on A brief history of Sahana by S…
    James Murray on On being the maintainer, sole…
  • Archives

  • Blog Stats

  • Top Posts

  • Top Rated

  • Recent Posts

  • Archives

  • Top Rated

  • %d bloggers like this: