Carla is attending a concert and she has to use the bathroom. Unfortunately, the concert venue has only one Porta-Potty! There are 10 people in line, and each person in line takes either 1, 2, 3, 4, or 5 minutes to go to the bathroom. If Carla had to wait 35 minutes to use the bathroom, how many possible ways could the people ahead of her have used the bathroom? In other words, how many ways can we fill a multiset of 10 elements with the numbers 1, 2, 3, 4, and 5 such that their sum is 35?
Details and Assumptions
For example, People 1 through 5 could all have used the bathroom for 3 minutes, while People 6 through 10 could each have used it for 4 minutes. 5 × 3 + 5 × 4 = 3 5 , therefore this is one of the possible lines that Carla could have waited in.
Carla gets in line the moment that Person 1 begins to use the Porta-Potty.
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Great! I see that you've updated your solution from brute force computing to a combinatorial understanding.
Can you explain the thought process to arrive at the formula listed? Why is it true?
Hint: Principle of Inclusion and Exclusion .
You have the rest of the ideas needed.
Log in to reply
Yes we can use PIE, but when i read the problem it comes to my mind the equation x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 <=35 not equal 35, whether 1<= xi <=5 . In the end, we should solve manually.
You have a fan now. I've seen two of your Combinatorics problems (the chess one was crazy like what) and both are extremely nice. You deserve much more followers.
Log in to reply
Thank you, that's so nice of you to say! I'm posting a new combinatorics problem today actually, watch out for it!
Log in to reply
I'm gonna admit I applied the cheat for this problem and used the same solution as Melissa's. But I really want to know how you arrived at the formula.
The number of orders is the coefficient of x 3 5 in the series expansion of ( x + x 2 + x 3 + x 4 + x 5 ) 1 0 = x 1 0 ( 1 − x 5 ) 1 0 ( 1 − x ) − 1 0 = x 1 0 ( j = 0 ∑ 1 0 ( − 1 ) j ( j 1 0 ) x 5 j ) ( j = 0 ∑ ∞ ( 9 j + 9 ) x j ) and hence is equal to j = 0 ∑ 5 ( − 1 ) j ( j 1 0 ) ( 9 3 4 − 5 j ) = 4 7 3 6 9 4 .
This problem is a perfect example of where generating functions can be used. The number of ways of choosing 10 numbers, each from the set {1, 2, 3, 4, 5} that add up to 35 is equal to the coefficient of x 3 5 in the expansion of ( x 1 + x 2 + x 3 + x 4 + x 5 ) 1 0 . Obviously, the problem with this method is that this then has to be multiplied out to find the coefficient of x 3 5 which takes a long time or requires the use of Wolfram Alpha but when multiplied out, the coefficient of x 3 5 is 4 7 3 6 9 4 which is the answer.
As you realized, the drawback is that the exact coefficient is hard to calculate. It simplifies the original calculation only by providing a simple framework of bookkeeping, instead of providing us deeper insights into potential approaches.
Generating function solutions are often more useful when we are able to manipulate them in a variety of ways. E.g. by relating them to known functions, convolution, differentiation/integration, etc.
This is great! Regardless of the time it took to get the answer in this case, I love the connection that was made here, using generating functions was a smart move. Thanks for the solution!
Melissa, FYI you can easily link to wiki pages by using the command:
[[wiki-start typing something
This will pull up a list of wiki pages that (currently) exact matches what you typed.
Log in to reply
Okay that's great, I didn't know that. Thankyou!
If we sum x + x 2 + x 3 + x 4 + x 5 as a GP, then determining the coefficient of x 3 5 is not that ghastly a task. Generating functions are still very useful in this context. See my solution, which shows how to derive the formula given by @Garrett Clarke .
Solve
x 1 + x 2 + x 3 + x 4 + x 5 + x 6 + x 7 + x 8 + x 9 + x 1 0 = 3 5
for 1 ≤ x i ≤ 5 , i = 1 , 2 , 3 , 4 , 5 , … , 1 0
Which is equal to
y 1 + y 2 + y 3 + y 4 + y 5 + y 6 + y 7 + y 8 + y 9 + y 1 0 = 2 5
for 0 ≤ y i ≤ 5 , i = 1 , 2 , 3 , 4 , 5 , … , 1 0
Let n ( S ) the number of non negative integral solutions of y 1 + y 2 + y 3 + y 4 + y 5 + y 6 + y 7 + y 8 + y 9 + y 1 0 = 2 5
n ( S ) = ( 2 5 1 0 + 2 5 − 1 ) = 5 2 4 5 1 2 5 6
Let A i the number of solutions for y i ≥ 5
Here we will use Principle of Inclusion and Exclusion - Multiple Sets
Let B i be the number of solutions of 1 ≤ c ≤ d ≤ … ≤ i ∑ ∣ A c ∩ A d ∩ … ∩ A i ∣
∣ A 1 ∩ A 2 ∩ A 3 ∩ A 4 ∩ … A 9 ∩ A 1 0 ∣ = 0 ◃ 1 0 × 5 ≥ 2 5
→ B 1 0 = 0
∣ A 1 ∩ A 2 ∩ A 3 ∩ A 4 ∩ … A 8 ∩ A 9 ∣ = ∣ A 2 ∩ A 3 ∩ A 4 ∩ … A 9 ∩ A 1 0 ∣ = 0 ◃ 9 × 5 ≥ 2 5
→ B 9 = 0
∣ A 1 ∩ A 2 ∩ … A 7 ∩ A 8 ∣ = ∣ A 2 ∩ A 3 ∩ … A 8 ∩ A 9 ∣ = ∣ A 3 ∩ A 4 ∩ … A 9 ∩ A 1 0 ∣ = 0 ◃ 8 × 5 ≥ 2 5
→ B 8 = 0
∣ A 1 ∩ A 2 ∩ … A 6 ∩ A 7 ∣ = ∣ A 1 ∩ A 2 ∩ … A 6 ∩ A 8 ∣ = ∣ A 1 ∩ A 2 ∩ … A 6 ∩ A 9 ∣ = ∣ A 1 ∩ A 2 ∩ … A 6 ∩ A 1 0 ∣ = … = ∣ A 2 ∩ A 3 ∩ … A 7 ∩ A 8 ∣ = … = ∣ A 4 ∩ A 5 ∩ … A 9 ∩ A 1 0 ∣ = 0
◃ 7 × 5 ≥ 2 5
→ B 7 = 0
∣ A 1 ∩ A 2 ∩ … A 5 ∩ A 6 ∣ = ∣ A 1 ∩ A 2 ∩ … A 5 ∩ A 7 ∣ = ∣ A 1 ∩ A 2 ∩ … A 5 ∩ A 8 ∣ = ∣ A 1 ∩ A 2 ∩ … A 5 ∩ A 9 ∣ = … = ∣ A 2 ∩ A 3 ∩ … A 6 ∩ A 7 ∣ = … = ∣ A 5 ∩ A 6 ∩ … A 9 ∩ A 1 0 ∣ = 0
◃ 6 × 5 ≥ 2 5
→ B 6 = 0
∣ A 1 ∩ A 2 ∩ A 3 ∩ A 4 ∩ A 5 ∣ = ∣ A 1 ∩ A 2 ∩ A 3 ∩ A 4 ∩ A 6 ∣ = ⋯ = ∣ A 2 ∩ A 3 ∩ A 4 ∩ A 5 ∩ A 6 ∣ = … = ∣ A 6 ∩ A 7 ∩ A 8 ∩ A 9 ∩ A 1 0 ∣ = 1
◃ 2 5 − 5 × 5 = 0 ◃ ◃ ( 0 1 0 + 0 − 1 ) = 1
→ B 5 = ( 5 1 0 ) × 1 = 2 5 2
∣ A 1 ∩ A 2 ∩ A 3 ∩ A 4 ∣ = ∣ A 1 ∩ A 2 ∩ A 3 ∩ A 5 ∣ = ⋯ = ∣ A 2 ∩ A 3 ∩ A 4 ∩ A 5 ∣ = … = ∣ A 7 ∩ A 8 ∩ A 9 ∩ A 1 0 ∣ = 2 0 0 2
◃ 2 5 − 4 × 5 = 5 ◃ ◃ ( 5 1 0 + 5 − 1 ) = 2 0 0 2
→ B 4 = ( 4 1 0 ) × 2 0 0 2 = 4 2 0 4 2 0
∣ A 1 ∩ A 2 ∩ A 3 ∣ = ∣ A 1 ∩ A 2 ∩ A 4 ∣ = ⋯ = ∣ A 2 ∩ A 3 ∩ A 4 ∣ = … = ∣ A 3 ∩ A 4 ∩ A 5 ∣ = … ∣ A 8 ∩ A 9 ∩ A 1 0 ∣ = 9 2 3 7 8
◃ 2 5 − 3 × 5 = 1 0 ◃ ◃ ( 1 0 1 0 + 1 0 − 1 ) = 9 2 3 7 8
→ B 3 = ( 3 1 0 ) × 9 2 3 7 8 = 1 1 0 8 5 3 6 0
∣ A 1 ∩ A 2 ∣ = ∣ A 1 ∩ A 3 ∣ = ⋯ = ∣ A 2 ∩ A 3 ∣ = … = ∣ A 3 ∩ A 4 ∣ = … ∣ A 7 ∩ A 9 = ∣ A 7 ∩ A 1 0 ∣ = ∣ A 8 ∩ A 9 ∣ = … ∣ A 9 ∩ A 1 0 ∣ = 1 3 0 7 5 0 4
◃ 2 5 − 2 × 5 = 1 5 ◃ ◃ ( 1 5 1 0 + 1 5 − 1 ) = 1 3 0 7 5 0 4
→ B 2 = ( 2 1 0 ) × 1 3 0 7 5 0 4 = 5 8 8 3 7 6 8 0
∣ A 1 ∣ = ∣ A 2 ∣ = ∣ A 3 ∣ = … = ∣ A 1 0 ∣ = 1 0 0 1 5 0 0 5 ◃ 2 5 − 1 × 5 = 2 0 ◃ ◃ ( 2 0 1 0 + 2 0 − 1 ) = 1 0 0 1 5 0 0 5
→ B 1 = ( 1 1 0 ) × 1 0 0 1 5 0 0 5 = 1 0 0 1 5 0 0 5 0
∣ ∣ ∣ ∣ ∣ i = 1 ⋃ n A i ∣ ∣ ∣ ∣ ∣ = i = 1 ∑ n ∣ A i ∣ − 1 ≤ i < j ≤ n ∑ ∣ A i ∩ A j ∣ + 1 ≤ i < j < k ≤ n ∑ ∣ A i ∩ A j ∩ A k ∣ − ⋯ + ( − 1 ) n − 1 ∣ A 1 ∩ ⋯ ∩ A 1 0 ∣
∣ ∣ ∣ ∣ ∣ i = 1 ⋃ 1 0 A i ∣ ∣ ∣ ∣ ∣ = B 1 − B 2 + B 3 − B 4 + B 5 − B 6 + B 7 − B 8 + B 9 − B 1 0
∣ ∣ ∣ ∣ ∣ i = 1 ⋃ 1 0 A i ∣ ∣ ∣ ∣ ∣ = 1 0 0 1 5 0 0 5 0 − 5 8 8 3 7 6 8 0 + 1 1 0 8 5 3 6 0 − 4 2 0 4 2 0 + 2 5 2 − 0 + 0 − 0 + 0
∣ ∣ ∣ ∣ ∣ i = 1 ⋃ 1 0 A i ∣ ∣ ∣ ∣ ∣ = 5 1 9 7 7 5 6 2
n ( ⋃ i = 1 1 0 A i ) = n ( S ) − n ( ⋃ i = 1 1 0 A i )
n ( ⋃ i = 1 1 0 A i ) = 5 2 4 5 1 2 5 6 − 5 1 9 7 7 5 6 2
n ( ⋃ i = 1 1 0 A i ) = 4 7 3 6 9 4
Problem Loading...
Note Loading...
Set Loading...
After careful analysis and trying many different ways of calculating this number, I've derived a formula for the number of ways to fill a set of size d with the numbers from 1 to m such that the elements of the set sum to n :
S ( d , m , n ) = k = 0 ∑ ⌊ m n − d ⌋ ( − 1 ) k ( k d ) ( d − 1 n − m k − 1 )
Plugging in d = 1 0 , m = 5 and n = 3 5 we get:
S ( 1 0 , 5 , 3 5 ) = k = 0 ∑ 5 ( − 1 ) k ( k 1 0 ) ( 9 3 5 − 5 k − 1 ) = 4 7 3 6 9 4