File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes combinations and permutations Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "combinations and permutations" Watch "combinations and permutations" New topic

combinations and permutations

chandrasekharareddy palugulla

Joined: Feb 09, 2007
Posts: 3
I have a two dimentional array
like String twoDimentions ={
{ "A", "B", "C", "D", "E", "F" },
{ "A", "B", "C", "D", "E" },
{ "A", "B", "C", "D" },
{ "A", "B", "C" },
{ "A", "B","C","D" }
twoDimentional arry length will be dynamically changing.
two dimentional array having single dimentional arrays.
length of single dimentional array dynamically changing.
now i want comination of String like "AAAAA","AAAAB","AAAAC","AAAAD","AAABA","AAABB","AAABC","AAABD","AAACA","AAACB","AAACC","AAACD".................."FEDCD".
here "AAAAA" means each character from different arrays,
each element coming from different different arrays,
total no of strings (combinations) should be 1st array * 2nd array * 3rd array........
for above example it should be having 6*5*4*3*4 = 1440
each string length should be equals to size of twodimentional array. each string length should not less or greather than length of two dimentional array.

please give answer..........
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46337
We don't simply give such answers. Please show us what you have achieved so far; pseudo-code might be the best thing to show us.

Then we shall be pleased to help with any problems you might encounter.
Piet Verdriet
Ranch Hand

Joined: Feb 25, 2006
Posts: 266
JosAH gave you some pretty good hints here:
The people over there also encouraged you to post your own efforts instead of asking for a spoon-fed-solution, which you didn't do.
Rob Spoor

Joined: Oct 27, 2005
Posts: 20271


Please Be Forthright When Cross Posting To Other Sites.

How To Ask Questions How To Answer Questions
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46337
Agree. Thank you for noticing, Piet.
I agree. Here's the link:
subject: combinations and permutations
It's not a secret anymore!