Subj : Re: combo numbering To : comp.programming From : Thad Smith Date : Thu Oct 06 2005 11:49 pm bob@coolgroups.com wrote: > If you have 52 cards and you choose 7, there are 133,784,560 > possibilities. > > So, let's say you have 7 playing cards. Is there an easy way to convert > these cards into a number between 0 and 133,784,559? I wrote a set of C functions a while ago to convert from a combination index to the combination, and the reverse. It has a lot more than you would need for this, but you are welcome to use it. The added complexity comes from allowing sets with some identical items and setting a maximum of the number of identical items in a combination. It also has code to detect arithmetic overflow in computing the index. The header file describes the interface. If you define TEST then the code will compile a test program to allow you to convert back and forth. http://home.ionsky.com/~thadsmith/combx.ZIP Thad .