Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Combinations (not permutations) of numbers

Does anyone have a method that I could use to print (or anything) all combinations (so, 123 and 321 are the same) of given numbers, or even something that would do the same to objects??
[185 byte] By [veggen] at [2007-11-11 8:38:18]
# 1 Re: Combinations (not permutations) of numbers
you want the different ways 123 could be printed? ex:
123
132
213
231
312
321
?
Sportsdude11751 at 2007-11-11 22:34:44 >
# 2 Re: Combinations (not permutations) of numbers
so you dont want all combinations, just all groups.

S = set of all numbers
C = number of elements in a combination, or group

So all possible groups equals S!/C!
Phaelax at 2007-11-11 22:35:49 >
# 3 Re: Combinations (not permutations) of numbers
Ummm... I don't think you got me...
Permutations, variations and combinations are not the same thing... Permutations are when total number of elements and a number of elements in a group are the same, so you just change their places (so, ordering metters)... variations are when you can group less elements than the maximum, but ordering still metters, and combinations are the same as variations except that ordering does not metter ie. 123, 213 and 321 are the same... and combinations are exactly what I need...
I want my program to take n elements and print out all combinations, meaning from combinations with 1 element to those with all n elements...
Any ideas??

Thanks
veggen at 2007-11-11 22:36:48 >