Click to See Complete Forum and Search --> : What is the best algorithm for...


jacen6678
09-26-2003, 12:13 PM
Does anyone know the most efficient way of iterating through all the possible distinct combinations if you are making X selections from Y unique options; 0<x<=y. For example:

What are all the combinations of cards you could get if you draw cards from a deck of 52 cards.

or

What are all the possible combinations of letters using each letter 0 or 1 times. (a, b, c... ab, ac... abc... but NOT aa. Once ab comes up, ba should not come up.)

The order of selections does not matter.

Jeff Mott
09-26-2003, 02:03 PM
There are formulas and techniques for calculating combinations and permutations, but there is no shortcut if you need to iterate through them all.