EDIT NOTE: I've not been very clear. I'm trying to start from a single char guess such as 0 to 00 to 000 ... all the way through to zzzzzz. Basically, all possible iterations from 0 to zzzzzz. Sorry I've not been very clear!
I'm currently trying to cycle through an array of characters. The array contains 0-9 and a-z (lower case). Admittedly, this is homework - I'm a useless coder (see previous post) and I could do with a bit of help.
What I want is to iterate through all possible results of the char array and list the results...
aaa aba
aab > through to > aca
aac ada
If it were just based on letters I've read that I could base it on base26 number system but this includes numbers.
So far, I've managed to cycle through the array, assign the answer to a 'guess' array before cycling through at the next position. After that, I'm stumped.
Any advice, as last time, much appreciated. The work is based on Brute Force but there are plenty of working examples out there for me to use if my true aim was illegal, but it's not.
Here is what I have so far.
/**
*
* @author Aaron
*/
public class Test {
/**
* @param args the command line arguments
*/
int current = 0;
char[] guess = new char[6];
public static void main(String[] args) {
Test test = new Test();
int maxLength = 6;
char c = '0';
while (maxLength != 0) {
maxLength--;
test.iterateAll(c);
test.increment(c);
}
}
public void iterateAll(char c) {
char[] charset = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
'u', 'v', 'w', 'x', 'y', 'z'};
for (int i = 0; i < charset.length; i++) {
//c = charset[i];
guess[current] = charset[i];
System.out.println(guess);
}
}
public void increment(char c) {
current++;
}
}