aspose file tools*
The moose likes Beginning Java and the fly likes Challenging permutation - combination of strings Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Challenging permutation - combination of strings" Watch "Challenging permutation - combination of strings" New topic
Author

Challenging permutation - combination of strings

N Vinod
Greenhorn

Joined: May 13, 2002
Posts: 2
Hey guys, here is some real brain twisting tough one...tough for me atleast....
If i have a set of values, say,
ABCDE
GHIJKL
MNOPQR

each line stored as an array of Strings, where the number of rows and colunmns can be dynamic and much larger.
I need to get the following output, for a permutation of data of "3 element combinations"
1)
ABC
GHI
MNO
2)
BCD
HIJ
NOP
3)
CDE
IJK
OPQ
4)
DEF
JKL
PQR
5)
ABD
GHJ
MNP
6)
ACD
GIJ
MOP
and so on..............
I was able to obtain the first four combinations, as it is pretty straight forward, using "for loops" and incrementing the values in substring() method.
What do u think i can do to get the remaining outputs, like output numbe five and greater ??Please note that
CBA
IHG
ONM
is not needed as it is similar to the first output.
Instead of "3 element combinations"... i should be able to give "4 element combination" and get the corresponding output for it.
I have been working on this for a long time, on and off for more than a month, do let me know of your valuable tips.
thanks
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Vinod,
We try to keep a given conversation contained to a single thread. It makes it much easier to follow, participate in, and learn from the conversation. I've closed your original posting and included a link from it to here.
Thanks
[ May 14, 2002: Message edited by: Dirk Schreckmann ]

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Let's get a look at the code you're using so far. Post it if you would please - and don't forget to surround it in the [ code ] and [ /code ] UBB tags to preserve the formatting.
Thanks
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Challenging permutation - combination of strings