Friday, June 13, 2008


A second post today--woot, it's a twofer.

I was asked to play a game this morning, a very simple word ladder. Go from FOUR to FIVE in 7 steps (6 in-between words). It's a pretty straight forward puzzle.

And that got me to thinking--I love solving puzzles like that and lots of other related mind games. And everyone at work knows it. They can get me distracted sooooo easily. Good thing I'm not a teacher or I'd never make it through a lesson on time.

Recently, I was asked (not really as a puzzle but....) "How would you test this software? It's a command line oriented program call randy that is supposed to take as input the size of random data to produce on stdout." I thought about it for a few minutes and at last a light bulb went off: Compress the results. If they are incompressible, it's evidence leaning toward the randomness. (Now that's not exactly true--even all zeroes could be random.)

The person who asked the question hollered and nearly fell out of her chair. You know why? That's not what she was worried about. She didn't think anyone could determine in white box format whether or not something was generating random data--she never even considered the possibility. (She merely wanted someone to send gibberish input to see what happened and to ensure when you asked for x bits, you got x bits.) But I saw it not as an interview question or quality assurance question--I saw it as a brain teaser. And brain teasers have brain teaser answers.... and if you want to measure for random, the brain teaser answer is to measure the results for compressibility. (At least in my mind.)

This is perhaps the geekiest posting I've ever blogged. I suspect I've been inspired by my cohorts and reading literature. Just for Fun by Linus Torvalds and David Diamond is the book I've just finished. I'm trying to teach my son how to do fractions (including complete factorization) and I work with people who send me puzzles--at least one a week and oft times more. Thanks HP.

No comments: