0

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

3
  • 5
    In other words, you want to display all combinations of length N where N is entered by the user? This sounds a bit homeworkish, if that's the case, use the homework tag. Commented Apr 13, 2011 at 13:12
  • Yes, but the letter will be displayed once, and if the current location is B, the letter A won't be displayed Commented Apr 13, 2011 at 13:14
  • 2
    Please review: codeproject.com/KB/recipes/Combinatorics.aspx It will help you with your homework. Commented Apr 13, 2011 at 13:17

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

3 Comments

I see.. Thanks I will try it out... but it is not a school assignment.
Can't the scenario I gave, be done by simple looping, not using any other classes..
Yes, it can. But most other examples will be using recursion, which confuses most people even more than classes do. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.