More on KSubsets

*Subject*: [mg2429] More on KSubsets*From*: wself at viking.emcmt.edu (Will Self)*Date*: Thu, 9 Nov 1995 04:41:42 GMT*Approved*: usenet@wri.com*Distribution*: local*Newsgroups*: wri.mathgroup*Organization*: Wolfram Research, Inc.*Sender*: daemon at wri.com ( )

Axel's question about KSubsets has some interesting variations. For example, there is another possibly useful order on the k-subsets, different from the lexicographic one. For a finite subset s of the non-negative integers, compute the number n such that the digits in the binary representation for n corresponding to elements of s are 1, and the rest of the digits are 0. For the set {0,1,3} the associated number would be 2^0 + 2^1 + 2^3 = 11. Now you can order the subsets s according to their associated numbers n. It's no problem to create the function nthSubset, which gives the nth subset in this ordering, but what about the function nthKSubset, which for a given k would return the nth k-subset in this ordering? Anyone have a nice way to do this? Will Self