# Five people get on the elevator that stops at five floors. In how many ways they can get off?

Five people get on the elevator that stops at five floors. In how many ways they can get off? For example, one person gets off at the 1st floor, two will get off at the third, and the remaining two at the fifth floor. In how many ways they can get off at different floors? Now, consider that people in elevator have names, say A,B,C,D and E., assuming that, for example, the case A on the 1st floor is different from the case B on the 1st floor. Answer the previous questions with this assumption.

I was told that there are 4 questions, but I'm not really sure about it.

1. People don't have names and get off
2. People don't have names and get off at different floors
3. People have names and get off
4. People have names and get off at different floors.

Do the names matter?

I think I can answer one question out of 4 - the number of all outcomes should be $5^5=3125$. I am confused about the rest though

• I think I can answer one question out of 4 - the number of all outcomes should be 5^5=3125. I am confused about the rest though. – Gabriel Oct 6 '17 at 16:33
• Wait, there are 4 questions here? I only see two: one where you do differentiate between the 5 people and one where you don't. And yes, for the second one you indeed get $5^5$. – Bram28 Oct 6 '17 at 16:36
• Do you know about Stars and Bars? – Bram28 Oct 6 '17 at 16:37
• Thank you!! I was told that there are 4 questions, but I'm not really sure about it. 1. People don't have names and get off, 2. People don't have names and get off at different floors, 3. People have names and get off, 4. People have names and get off at different floors. Do the names matter? And thank you, I will definetely read about Stars and Bars!! – Gabriel Oct 6 '17 at 16:52

1. This has been answered in other answers: ${9\choose4}$.

2. Since there are $5$ people and $5$ floors there is just $1$ way for them to get off at different floors: $1$ per floor.

3. You already found $5^5=3125$.

4. At each floor exactly one of $A$, $\ldots$, $E$ gets off. This can be done in $5\cdot4\cdot3\cdot2=5!=120$ ways.

For the first question, use the basic 'stars and bars' method.

We can represent your example scenario ("For example, one person gets off at the 1st floor, two will get off at the third, and the remaining two at the fifth floor.") as:

$$*||**||**$$

The people are the 'stars' and the separators between the different floors are the 'bars'.

Another example: one person getting off on each floor would be:

$$*|*|*|*|*$$

And everyone getting off on the 3rd floor would be:

$$||*****||$$

See how this works?

Now, with $4$ 'bars' to divide the people into the $5$ groups/floors, and those bars taking up $4$ of the $9$ possible positions in this 'symbol string' of bars and stars, you get

$$9 \choose 4$$

possibilities.

• Thank you so much for the explanation!! I think I understand how it works now. – Gabriel Oct 6 '17 at 16:54
• @Gabriel You're welcome! Your instructor did not teach 'stars and bars' yet? ... Because this was a typical stars and bars question! :) – Bram28 Oct 6 '17 at 16:56
• Sometimes they just give the formula derived from stars and bars which is $\dbinom{n+r-1}{r-1}$ in this case $n=5$ and $r=5$ of course, the integer solutions for the equation $x_1+x_2+x_3+x_4+x_5=5$ are considered there are no left and right boundries (luckily). Of course giving the formula without the logic is problematic but I haven't seen one problem that required the logic rather than the formula. – Deniz Tuna Yalçın Oct 6 '17 at 20:21

The question could also be solved using a well known formula derived from stars and bars which is; $$\dbinom{n+r-1}{r-1}$$ where we distribute $r$ equally accepted objects to $n$ spaces with or without restrictions like $\geq1$ or $\leq9$, this formula is also used for solving linear equations (in integers) that's why this works for combinatoric problems, so without making it longer;$$x_1+x_2+x_3+x_4+x_5=5$$ so we apply the formula, we can think that this is equivalent to distributing five equally accepted apples to five children for instance, the result is $$\dbinom{5+5-1}{5-1}=126$$ this statement could be proven using alternate ways, we should open a post about it too.