Letters/Numbers puzzle
May 31, 2006 /
Filed under: Projects
Here is the situation: You can use any number from 0-9, and any letter from A-Z. Now, come up with as many unique letter/number combinations, which can only be four characters in length. Feasibly, I started out like this: A000 - A999 is 1,000 different combinations. B000 - B999 is another 1,000 different combinations. Continue this until the first digit is the letter Z, you end up with 26,000 different combinations. Next, change the second digit to A, and proceed like this: AA00 - AA99 is 100 different combinations. BA00 - BA99 is another 100 different combinations. Continue this until the first digit is the letter Z, you end up with another 2,600 different combinations. This is where it gets confusing. Here is what I thought would be a logical next step: AB00 - AB99 is 100 different combinations. The second digit above - the letter B remains there. Now, we change the first digit: BB00 - BB99 is another 100 different combinations. Keep doing this until you get to: ZB00 - ZB99. That is another 2,600 different combinations. Lost yet? (I am getting there.) The idea is to get as many different combinations of unique letters/numbers, so we never run out. With only four digits, it is probably not possible, but this approach seems to give the most flexibility. Comments/Mentions# Matthom at 5/31/2006 2:29 pm cst
Wow that is helpful. I really needed that information. It’s actually not a "puzzle" at all. At least, not just for fun. It’s for work, and I am limited to a Thanks a bunch! |
Recent Comments
Recent Music Listens
|
There should be 1,413,720 different permutations.
Number of characters = 10 + 26 = 36
Length of string = 4
P(36, 4) = 36! / (36 - 4)! = 1,413,720
See http://en.wikipedia.org/wiki/Permutation
Was the puzzle to find out how many permutations there were, or how to actually generate the permutations?
List permutations = new ArrayList(1413720);
for (int i = 0; i < 36; i ) {
for (int j = 0; j < 36; j ) {
for (int k = 0; k < 36; k ) {
for (int m = 0; m < 36; m ) {
char a = figureOutCharacterFor(i);
char b = figureOutCharacterFor(j);
char c = figureOutCharacterFor(k);
char d = figureOutCharacterFor(m);
permutations.add(a b c d);
}
}
}
}
There’s probably a more generalized way to do this recursively, so that you could plug in any permutation length and character set length.