Here's the situation:
I have 36 characters to choose from, a-z and 0-9.
char[] alphabet = "0123456789abcdefghijklmnopqrstuvwxyz".toCharArray();
And using an index, we want to create all possible strings of length N, from N = 1 to N = 2.
A length of 1 is rather simple,
private String generateString(int index){
if (index < 36){
char word = alphabet[index];
return String.valueOf(word);
}
if ( index < 1332) {
//lost
}
}
But what if we wanted a length of 2, well we can assume that all words of length 2 will have an index of > 36 and < 1332 (36 + (36^2)). But I am lost on how to relate these indexes to a word with length 2, and making sure all possible word combinations are hit.
I think there is a mathematical way to accomplish this, but I am just not seeing it.