# Combinations of two sets

I'd like to confirm, what is the name of this combination, and if its calculated right:

Set (a,b) is spread over set of (1,2,3)

1 2 3
a b

a1 b1 2 3
a1 b2 3
a1 2 b3
b1 a2 3
b1 2 a3
1 a2 b2 3
1 a2 b3
1 b2 a3
1 2 a3 b3


2*3 + 3 = 9

And based on that I'm doing it with a bigger sets without manual trial and error:

1 2 3 4 5 6 7 8 9 10 11 12
a b c d e f g


7*12 + 12 = 96

-
The meaning is unclear. Your worked example suggests you are counting the maps from {a,b} to {1,2,3}, which is 3^2 = 9. However in the second case the answer would be much bigger than 96 if that were the meaning. –  hardmath Mar 25 '12 at 7:28

If $a$ can take any of $3$ possible values, and independently $b$ can take any of $3$ possible values, then in total there are $3 \times 3 =9$ possibilities.

So with $m$ letters each taking $n$ possible values there are $n^m$ possibilities.

With $7$ letters and $12$ values this is $12^7 = 35831808$ possibilities, rather more than your $96$.

-
Yes, a and b can take any possible value independently, and they must to take one value plus same combination is count only once. But I'm not really sure, if combinations can be that big tens millions... –  PHPGAE Mar 25 '12 at 18:27
@PHPGAE: Try with one letter and twelve values: the answer is obvious $12$ possibilities. Now with a second letter, that has $12$ possible values too so combined you have $12 \times 12$ possibilities. Now with a third letter, that has $12$ possible values as well so combined you have $12 \times 12 \times 12$ ... –  Henry Mar 25 '12 at 21:00

If I understood your question correctly general formula should be :

$$N= \frac{n!}{(n-k)!}+n$$

where $n$ is a number of elements of numbers set , and $k$ is number of elements of letters set .

-
I was thinking something similar to this factory number crunching, but problem in this formula is, that if alpha set and number set count both are 3, then n-k will be 0 and calculation fails... –  PHPGAE Mar 25 '12 at 18:29
Actually 0! is well-defined and equal to 1, so @pedja 's formula doesn't "fail". However I'm unable to tell "the name of this combination" or indeed just what you are trying to count here. –  hardmath Mar 25 '12 at 22:08
Oh, I must have messed with my mac calculator cause I got undefined number with calculation, but yes 0! gives 1 now. I can't explain much more, but I just want to get all positions letters can take on number set. Say there are 6 different sections on a circle plate and 3 different items to put on sections. If you throw items on a plate, they take random places and I want to get the count of combinations they (3 three items on 6 sections) can take. –  PHPGAE Mar 26 '12 at 1:45

Actually @Henry might be right after all. I made further construction with a set of 1, 2, 3, 4 and a, b:

a1 b1 2 3 4
a1 b2 3 4
a1 2 b3 4
a1 2 3 b4
b1 a2 3 4
b1 2 a3 4
b1 2 3 a4
1 a2 b2 3 4
1 a2 b3 4
1 a2 3 b4
1 b2 a3 4
1 b2 3 a4
1 2 a3 b3 4
1 2 a3 b4
1 2 b3 a4
1 2 3 a4 b4


To compare my earlier formula that coincidently happened to give right answer, we can see:

2*4 + 4 = 12 != 4^2 = 16

I was confused with the pattern, that you can see from the example result. There are 4 rows popping up from other rows with certain interval. I think that pattern kind of "fractalizes" depending how many items there are on sets. But thats another story.

-