I\'m attempting to write a program that will generate a text file with every possible permutation of the alphabet from one character up to twenty-nine characters. I\'ve chosen 2
A Java solution that should do the trick:
public void characterPermutations(int length, LinkedList permutations) {
if(length > 1) {
characterPermutations(length - 1, permutations);
ListIterator iterator = permutations.listIterator();
while(iterator.hasNext()) {
String permutation = iterator.next();
for(char c = 'a'; c <= 'z'; c++) {
iterator.add(c + permutation);
}
}
} else {
for(char c = 'a'; c <= 'z'; c++) {
permutations.add(c + "");
}
}
}