Letters/Numbers puzzle May31 '06

Feedback

# (1 of 2): Jennifer Grucza » jennifergrucza.com

4 hours, 30 minutes after the fact. (Wed 31 May 2006, 4:06 PM CST)

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.

# (2 of 2): Matthom

4 hours, 53 minutes after the fact. (Wed 31 May 2006, 4: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 char(4) column type, for various, off-topic reasons. In any case, I need to use this 4 character field to generate as many unique combinations as possible - so the combinations don’t ever run out, for the project. I’m thinking I need at least 500,000 unique combinations - because this is for keeping track of physical street addresses, and we have a lot. If you say I should be able to generate over a million unique, then that’s awesome. I’m gonna look into that Wiki page further, and ask you if I have more questions.

Thanks a bunch!

Previous comment Return to entry

RSS feed for comments on this post

Leave feedback

Feedback

Input format: The editor controls below will assist with Markdown syntax.

Status

Sub-status

Your info

Return to entry.

Using any number from 0-9, and any letter from A-Z, come up with as many unique letter/number combinations, which can only be four characters in length.

You are at the feedback permalink page for: Letters/Numbers puzzle

Read more...