Cicco
Cicco

Reputation: 1

Looping through an array of strings

I have an array with letters for example

string[] arrayLetters = new string[] {"A","B", "C", "D"}

and so on.

Now a user will type in the number of sets he want to display...

if for example he types in 2, then the output would be:

AB,AC,AD, BC, BD

For a set of three, the output would be like:

ABC, ABD, ACD, BCD

... and so on.

Can you please help me solve this little scenario I have?

Thanks Mark Montebello the Cicco

Upvotes: 0

Views: 224

Answers (1)

Panagiotis Kanavos
Panagiotis Kanavos

Reputation: 131180

This Code Project article gives a good overview of combinations (what you are asking), permutations etc and provides a library for calculating them in C#. It's just one of the many libraries that provide this functionality.

BTW combinatorics is introductory computing material. That's why people suspect this may be a school assignment.

Upvotes: 2

Related Questions