# Combination/Permutation Question

I'm trying to solve a programming challenge, and I have narrowed down all the challenge to a combination/permutation problem.

I ended up with 5 possible scenarios, and I need to find all possible combinations in such scenarios, but I'm not really sure if my results or my line of thought is correct. I'd like to have some feedback on this matter.

Scenario 1:

an 11 elements long list that must arrange 1 A, and 10 B's in every possible way

Scenario 2:

a 12 elements long list that need to arrange 4 A's and 8 B's in every possible way

Scenario 3:

a 13 elements long list that need to arrange 7 A's and 6 B's in every possible way

Scenario 4:

a 14 elements long list that need to arrange 10 A's and 4 B's in every possible way

Scenario 5:

a 15 elements long list that need to arrange 13 A's and 2 B's in every possible way

e.g. For the first scenario I have 11 possible ways to arrange the list.

1.  A B B B B B B B B B B
2.  B A B B B B B B B B B
3.  B B A B B B B B B B B
4.  B B B A B B B B B B B
5.  B B B B A B B B B B B
6.  B B B B B A B B B B B
7.  B B B B B B A B B B B
8.  B B B B B B B A B B B
9.  B B B B B B B B A B B
10. B B B B B B B B B A B
11. B B B B B B B B B B A


For Scenario 2, I tried to do nCr(12,4) = 495

but I also thought a way to figure out the amount of combinations this way: since 4 slots must be A's and 8 slots must be B's 2^4 + 2^8 = 272

Chances are that both are wrong, but I've been working in this problem for about 4 hours straight and I can't think clearly.

Any help would be greatly appreciated!

-

Your answer to 1 is correct, as it the 495 for 2. The same logic as for 2 (you have 12 slots and need to pick 4 for the B's) will handle the rest.

-
Thank you a lot for letting me know that 495 was correct for 2 :) – AlanChavez Nov 15 '12 at 3:26

I usually proceed as follows (total ways)! divided by the repeats factorial

Example 3A and 4B and 6C = 13!/(3! x 4! x 6!)

your example no2 = 12!/(4! x 8!) = 495 no 3 = 13!/(7! x 6!) cheers

-
Yeah! that's the way to go about it! :-) – Rajendra Kumar Uppal Dec 3 '12 at 2:22