Max number of patterns when extending unique vector?

69 Views Asked by At

I'm not sure how to explain this correctly, so I hope the example at the end helps. I have unique vectors of different lengths, and I want to find the maximum number of variations possible of keeping the order, but extending the length to match another.

For example:

$(2,3)$ as length $3$ can be either $(2,2,3)$ or $(2,3,3)$.

I have manually written out different scenarios in order to see if there's a pattern to the numbers, but after looking at the answers below, I can't see an obvious answer. I'm presuming there's a theorem or equation that holds my answer, but I'm not from a maths background (I'm doing CS) and can't seem to find it. As I said, I manually wrote out the combinations for the following possibilities, so if I made a mistake forgive me.

original length $\rightarrow$ length needed: possible patterns

2 $\rightarrow$ 3: 2

2 $\rightarrow$ 4: 3

3 $\rightarrow$ 4: 3

3 $\rightarrow$ 5: 6

3 $\rightarrow$ 6: 10

3 $\rightarrow$ 7: 15

3 $\rightarrow$ 8: 21

4 $\rightarrow$ 5: 4

4 $\rightarrow$ 6: 10

4 $\rightarrow$ 7: 20

4 $\rightarrow$ 8: 35 * I think, I can't see any other possibilities

My problem is that although it's fine to write out these small numbers, I can't manually write out all possibilities for $3$ $\rightarrow$ $x$ where $x$ could be $>50$.

Is there a theorem or equation I should look up? Any help would be greatly appreciated!

1

There are 1 best solutions below

1
On BEST ANSWER

From what I understand, you have a sequence of length $n$ of distinct terms $(a_1, a_2, \dotsc, a_n)$, and you want to repeat some of the existing terms $a_i$ to pad out the sequence to be of length $m$.

Observe that you have exactly $m-n$ spaces to fill, where the values can be chosen from any of the $n$ existing terms $a_i$, and a term can be repeated multiple times.

This is the problem of unordered sampling with replacement, i.e. choose $p$ values out of $q$ possibilities with replacement, where the order in which we choose does not matter. The number of ways to do this is $$ \pmatrix{p+q-1 \\ q} = \frac{(p+q-1)!}{q!((p+q-1)-q)!} = \frac{(p+q-1)!}{q!(p-1)!}$$ where the bracket on the left hand side is a binomial coefficient.

For your problem we have $p=m-n, q=n$, and the formula is

$$ n \rightarrow m = \pmatrix{m-1 \\ m-n}.$$