I am trying to build some sort of string generator in Java, but haven’t got much luck so far to get it working the way I need it to work. This is also why I would like to ask someone with more experience to give me a hand with this task.
I am new in to java and programing in general, but I hope I should be able to understood tips from those of you who are more advanced on the subject.
What I want to do:
I want to use let’s say 10 characters i.e.
char[] volumeArray = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k'};
And generate 5 letter long strings including almost all possible variations based on volumeArray, only condition I need to get across is that single character can only be used maximum twice within a generated 5 character string i.e.
aaaab – not acceptable
aabbc or abbac – such combination is ok, letters can repeat themselves maximum twice in a single string but variations have to include all possible combinations including all the letters from volumeArray
I wanted to use codes from here: How to generate a random alpha-numeric string? but I didn’t succeed to modify these to my needs.
I also used crunch in Linux but there is no parameter that would allow me to specify single character to be used only twice within generated string, also using 26 letters in this manner will generate enormous file.
Guys would you be able to help me create piece if code that would meet above requirements and write output to a file?
I appreciate any help and please accept my apologies if this is to simple task to be answer in here.
Kind Regards Mariusz