Wow, this is so neat. I spent some time thinking about this problem years ago, and never thought of such an elegant solution.