# Permutation / Combination

Mani Ram

Ranch Hand

Posts: 1140

posted 12 years ago

- 0

I don't know whether this thread belongs to this forum but I couldn't any other forum appropriate for this discussion and so I'm posting it here.

Could somebody answer me with the formula for the following cases?

1) How many combinations are possible to create an alphanumeric string with a format XXXnnn where X is an uppercase letter (A-Z) and n is a digit (0-9)?

2) What if the format is flexible (say unlike the previous example even XnnXXn are nnXXnX are valid strings)? How many combinations are possible now?

3) What if the number of letters and digits in the resultant string is flexible. For example the string can be full of letters (XXXXXX) or of digits (nnnnnn) or anything in between?

4) How many combinations are possible if the lowercase letters are allowed (like XxXnXn)?

Could somebody answer me with the formula for the following cases?

1) How many combinations are possible to create an alphanumeric string with a format XXXnnn where X is an uppercase letter (A-Z) and n is a digit (0-9)?

2) What if the format is flexible (say unlike the previous example even XnnXXn are nnXXnX are valid strings)? How many combinations are possible now?

3) What if the number of letters and digits in the resultant string is flexible. For example the string can be full of letters (XXXXXX) or of digits (nnnnnn) or anything in between?

4) How many combinations are possible if the lowercase letters are allowed (like XxXnXn)?

Mani
*Quaerendo Invenietis*

posted 12 years ago

Well, if you allow both lower and uppercase than you'll have 52 possibilities instead of 26. Same rule apply as above.

Hope that helps.

- 0

Originally posted by Mani Ram:

I don't know whether this thread belongs to this forum but I couldn't any other forum appropriate for this discussion and so I'm posting it here.

Could somebody answer me with the formula for the following cases?

1) How many combinations are possible to create an alphanumeric string with a format XXXnnn where X is an uppercase letter (A-Z) and n is a digit (0-9)?

If you allow repeated alphanumeric: 26 x 26 x 26 x 10 x 10 x 10

If you disallow repeated alphanumeric: 26 x 25 x 24 x 10 x 9 x 8

2) What if the format is flexible (say unlike the previous example even XnnXXn are nnXXnX are valid strings)? How many combinations are possible now?

Same as above, as it has the same number of elements

3) What if the number of letters and digits in the resultant string is flexible. For example the string can be full of letters (XXXXXX) or of digits (nnnnnn) or anything in between?

For combination, you'll go for the highest probability,

so with 6 digit, you'll have 26 ^ 6 here.

4) How many combinations are possible if the lowercase letters are allowed (like XxXnXn)?

Well, if you allow both lower and uppercase than you'll have 52 possibilities instead of 26. Same rule apply as above.

Hope that helps.

Timothy Chen Allen

Ranch Hand

Posts: 161

posted 12 years ago

Be careful here. You actually have the possibility of 26 + 10 characters in each slot now, so it becomes 36 * 36 * 36 * 36 * 36 * 36.

- 0

Originally posted by Wirianto Djunaidi:

) What if the number of letters and digits in the resultant string is flexible. For example the string can be full of letters (XXXXXX) or of digits (nnnnnn) or anything in between?

For combination, you'll go for the highest probability,

so with 6 digit, you'll have 26 ^ 6 here.

Be careful here. You actually have the possibility of 26 + 10 characters in each slot now, so it becomes 36 * 36 * 36 * 36 * 36 * 36.

posted 12 years ago

does order matter? i.e. is AAA111 different than 1A11AA? this is not the same as case 1, i think...

- 0

2) What if the format is flexible (say unlike the previous example even XnnXXn are nnXXnX are valid strings)? How many combinations are possible now?

does order matter? i.e. is AAA111 different than 1A11AA? this is not the same as case 1, i think...

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors

Mani Ram

Ranch Hand

Posts: 1140

posted 12 years ago

- 0

Thanks for all.

Which totals to '26 x 26 x 26 x 10 x 10 x 10' elements as you said.

But, if strings like XnnXXn and nnXXnX are allowed, then the set should be bigger..isn't it?

Like

Yes. AAA111 is different from 1A11AA.

[ November 05, 2003: Message edited by: Mani Ram ]

Which totals to '26 x 26 x 26 x 10 x 10 x 10' elements as you said.

But, if strings like XnnXXn and nnXXnX are allowed, then the set should be bigger..isn't it?

Like

*A09BC2, 12DF3G*will also be eligible candidates which are not present in the above list.Originally posted by fred rosenberger:

does order matter? i.e. is AAA111 different than 1A11AA? this is not the same as case 1, i think...

Yes. AAA111 is different from 1A11AA.

[ November 05, 2003: Message edited by: Mani Ram ]

Mani
*Quaerendo Invenietis*

Mani Ram

Ranch Hand

Posts: 1140

posted 12 years ago

- 0

So, from your responses

-For a string with format XXXnnn, the possibilities are 26X26X26X10X10X10

-For a string which doesn't mandates the number of digits or letters in it (ex: 111111, FFFFFF are valid entries), the possibilities are (26+10)^6

-Replace 26 with 52 in the above equations, if lower case letters are allowed.

Still, one question remains: For flexi formats (like XnXnnX), the possibilities are ?

-For a string with format XXXnnn, the possibilities are 26X26X26X10X10X10

-For a string which doesn't mandates the number of digits or letters in it (ex: 111111, FFFFFF are valid entries), the possibilities are (26+10)^6

-Replace 26 with 52 in the above equations, if lower case letters are allowed.

Still, one question remains: For flexi formats (like XnXnnX), the possibilities are ?

Mani
*Quaerendo Invenietis*

Deb Sadhukhan

Ranch Hand

Posts: 67

Mani Ram

Ranch Hand

Posts: 1140

posted 12 years ago

- 0

Okay understood.

So, to create a string of 8 characters, with exactly 4 digits[0-9] and 4 letters[A-Z], with the following rules,

-Only UPPERCASE letters are allowed.

-Any character (letter or digit) can sit in any place.

The number of possible combinations are

(26*26*26*26*10*10*10*10) + (8! / 4! * 4!) =>

Right / Wrong?

So, to create a string of 8 characters, with exactly 4 digits[0-9] and 4 letters[A-Z], with the following rules,

-Only UPPERCASE letters are allowed.

-Any character (letter or digit) can sit in any place.

The number of possible combinations are

(26*26*26*26*10*10*10*10) + (8! / 4! * 4!) =>

**319883200000**Right / Wrong?

Mani
*Quaerendo Invenietis*

It is sorta covered in the JavaRanch Style Guide. |