# How many ways are there to place 2 types of objects in n (that varies) spots?

First time posting, all help appreciated. I'm trying to figure out the number of ways to arrange items in spots. The complication is that the number of spots changes with the type of items put in them.

Basically, I want the total of the objects (either 1 or 2) to be some number, say 10. So, if I choose all 1's, there will be ten spots and 1 way to arrange them. If I choose 1 for eight of the spots and 2 for one of them (the total is still 10), I have 9 ways to arrange them (see example below):

2, 1, 1, 1, 1, 1, 1, 1, 1

1, 2, 1, 1, 1, 1, 1, 1, 1

1, 1, 2, 1, 1, 1, 1, 1, 1

etc.

If I choose two 2's, I get even more choices. Inititially I predicted it would be a summing series (n + (n-1) + (n-2) + ... 2 + 1), but when I count it out, that's not what I get. Here is two 2's (and eight spots):

2, 2, 1, 1, 1, 1, 1, 1

2, 1, 2, 1, 1, 1, 1, 1

2, 1, 1, 2, 1, 1, 1, 1

etc.

(When I do it out manually like this, I think there are 13 combinations.)

So how would I calculate how many ways there are to rearrange the rest? Examples: three 2's and four 1's (writing them out, I also got 13 different combinations for this) or four 2's and two 1's (for this, I got 9).

Thanks!

• You are really looking at (a restricted) partition of 10 – kjetil b halvorsen Nov 10 '18 at 23:41

When there are $$k$$ 2's, there must be $$10-2k$$ 1's. So, number of ways to arrange these is $${10-k} \choose {k}$$. $$k$$ can range from $$0$$ to $$5$$. So, total way of doing this is: $$\sum_{k=0}^{5}{{10-k} \choose k}=1+9+28+35+15+1=89$$
You are probably missing some combinations while writing them out. It's not $$13$$ when there are two $$2$$'s, instead there are $$28$$ different combinations.