Click here to Skip to main content
15,907,913 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello, programmers!

I'm experiencing the following problem - I have 2D array 2x3 named arr, containing the letters from a to f as shown below:

C#
String[,] arr = new String[2, 3]
{
    { "a", "b", "c" },
    { "d", "e", "f" }
};


My purpose is to combine all the items from the first column (a, d) with all the items from the second column (b, e) with all the items from the third column (c, f). Like this:

C#
a b c
a b f

a e c
a e f

d b c
d b f

d e c
d e f


Is there any formula that makes my desired solution possible? I'm stuck when it comes to programming combinatorics. Thanks in advance for any help provided! :)
Posted
Comments
[no name] 13-Jul-13 21:29pm    
What you are looking for is called "permutations" and this http://www.google.com/search?q=c%23+array+permutations should get you started.
Sergey Alexandrovich Kryukov 14-Jul-13 0:03am    
A formula? For this?! Yes, there is. This formula is called "human brain". This is all you really need.
Please start here: http://whathaveyoutried.com.
—SA
Sergey Alexandrovich Kryukov 14-Jul-13 0:07am    
And please stop posting non-answers as "solution". It can give you abuse reports which eventually may lead to cancellation of your CodeProject membership.
Comment on any posts, reply to available comments, or use "Improve question" (above).
Also, keep in mind that members only get notifications on the post sent in reply to there posts.
You've posted 6 "answers", but non of them is not really an answer. Please don't do it.
—SA

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900