lundi 27 juin 2016

Generating all combinations (not all permutations) of n characters with length up to n

How can we generate all the possible combinations of n characters with length 1 to n in an increasing order of length?

For Example : if n = 4 and characters are 1,2,3,4 we need to print

1,2,3,4
12,13,14,23,24,34
123, 124, 134, 234
1234

Here n is the variable and user can feed the n characters.

Aucun commentaire:

Enregistrer un commentaire