How would you calculate the total unique combinations given a list of M elements padded with N additional elements (all the same) at any indexes within the list?
For example, say you have the list m = [a, b, c], and you want to generate all combinations padded with elements n = [z], this would generate 4 combinations, [z, a, b, c], [a, z, b, c], [a, b, z, c], [a, b, c, z].
For m = [a, b, c, d] and n = [z, z], it becomes more complex, with the result having 15 unique combinations, like, [z, z, a, b, c, d], [z, a, z, b, c, d], etc.
I'm trying to write a formula, f(m,n), that will return the total number of combinations, but I'm not sure how to handle the uniqueness factor. At first I thought it was simply f(m,n) = (m+1)*n. That predicts correctly for m=3,n=1 and m=4,n=1 but that fails to predict for m=4 and n=2, which results in 15 unique combinations.
So then I thought it was a summation of these functions, like:
f(m,n) = sum((m+1)*(n-i) for i in range(n))
This correctly predicts 15 for the inputs of m=4,n=2, but again fails for m=4,n=3, which is 35.
What am I missing?