TITLE: Number of binary solutions of $ \sum_{i=1}^{100} x_i = 20 $ for all $ 1 \leq i \leq 100$
QUESTION [0 upvotes]: Question: How many solutions does the following equation have?: $ \sum_{i=1}^{100} x_i = 20 $ s.t. $ x_i \in \{ 0 ,1 \} $ for all $ 1 \leq i \leq 100$ .
Answer: The question is identical to the problem where we have 100 cells ( which are the $ x_i $ ) and we need to distribute 20 identical balls into the cells s.t. in every cell we have at most 1 ball, hence the answer is $ { 100 \choose 20 } $.
I was wondering if there exists a way to approach this problem using "Stars and Bars" encoding? if show, what is the general encoding scheme in this problem?
Note: There are two questions related - How many solutions does the equation $\sum_{i=1}^{k}{x_i}=c$ have, given that the $x_i\in\mathbb{Z}$ and $0\leq x_i\leq d$?
and How many integer solutions of $x_1+x_2+x_3+x_4=28$ are there with $-10 \leq x_i \leq 20$?
However, the answer for 1st question talks about generating functions which I've not learned yet and the answer for the 2st question perhaps can be applied here carefully but I wanted to know if there is a simpler approach.
Attempt:
For example, I've interpreted the solution $ ( x_1  = 1 , x_2 = 1,..., x_{20}=1,x_{21}=0,...,x_{100} = 0   )$
as the encoding: $ *|*|...|*|||...| $ ( There are 20 stars and 99 bars ).
Thus the answer is $ { n + k - 1 \choose n-1 } = { 100 + 20 - 1 \choose 100 - 1 } = { 119 \choose 99 }  $.[ This answer is clearly wrong, but the encoding seems reasonable to me - what's the problem with it?]

REPLY [2 votes]: The problem in your suggested encoding is that the number of stars within one compartment could be greater than 1. For example, if you place all bars between the first two stars this encodes 1+19 which is not allowed in your setting.
So you should first set a bar between each two stars (which makes up 19 bars) and place the remaining 81 bars elsewhere. Therefore, you calculate
$$\binom{81+20-1}{81-1}=\binom{100}{80}=\binom{100}{20}$$
which gives you the same result.
{"set_name": "stack_exchange", "score": 0, "question_id": 4109616}