How many ways are there for 5 people to be friends with each other on Facebook, such that each person is friends with at least 1 other person in the group.
Details and assumptions
Facebook friendship is mutual. If A is friends with B , then B is friends with A .
2 ways are considered distinct, if the status of friendship between 2 people changed. For example, if A and B are friends, and C , D , E are all friends with each other, then this is a different way from if A and E are friends, and B , C , D are all friends with each other.
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.
I got 768 by: 1 0 C 1 0 + 1 0 C 9 + 1 0 C 8 + 1 0 C 7 + ( 1 0 C 6 − 5 ) + ( 1 0 C 5 − 5 ⋅ 6 ) + ( 1 0 C 4 − 5 ⋅ ( 6 C 4 ) ) + ( ( 5 C 2 ) ⋅ ( 3 C 2 ) ) = 7 6 8
Hi Do you mind explaining why you need 1024 - 320 + 80 -20 +5 -1? When you are counting the number of way for 1 person not to be friends with other, isn't 320 include the number of ways for 2,3,4,5 people not to be friends with others? Because when you isolate 1 person, in the 2 6 , isn't the 2 persons not to be friends with others included inside as well?
I have considered those possible ways out of the 2^10 in total that do NOT have every person friends with at least 1 other person in the group.
If there are only 0, 1 or 2 friendships, this is definitely the case. There are 10C0, 10C1 and 10C2 ways of this happening respectively.
If there are 3 friendships, then the cases can be counted by eliminating one of the people and then counting the ways of 3 friendships between the rest (out of the 6 possible friendships remaining), i.e. 5 x 6C3. We must note here that we will have counted friendships that are cycles of 3 twice (and there are 5C3 of them). We must subtract that number.
If there are 4 friendships it is only possible to exclude one friend, and in 5 x 6C4 ways.
If there are 5 friendships the same applies - 5 x 6C5
And with 6. 6 x 6C6.
If there are 7 or more friendships, it is impossible for the condition in the problem not to be held.
Therefore there are 2^10 - (10C0 + 10C1 + 10C2 + 5 x 6C3 - 5C3 + 5 x 6C4 + 5 x 6C5 + 5 x 6C6) = 768 ways.
Meh I used up all my solutions so I'll just post mine here.
Let A n be the answer for n people. Creary A 2 = 1 . (also A 0 = A 1 = 1 )
We can find A n from A n − 1 , A n − 2 , … by complementary counting.
There are n people, so there are 2 ( 2 n ) possible ways to friend them. Now we count the number of ways such that at least one person is not friends with anyone else. We now have n cases:
Case 1: 1 person is alone.
There are ( 1 n ) ways to choose this person. Now the problem is reduced to friending n − 1 people such that each person is friends with at least one other person, which is just A n − 1 ways. Thus there are a total of ( 1 n ) A n − 1 total ways.
Case 2: 2 people are alone.
There are ( 2 n ) ways to choose the people. Now the problem is reduced to friending n − 2 people such that each person is friends with at least one other person, which is just A n − 2 ways. Thus there are a total of ( 2 n ) A n − 2 total ways.
...
Case k : k people are alone. ( 1 ≤ k ≤ n )
There are ( k n ) ways to choose the people. Now the problem is reduced to friending n − k people such that each person is friends with at least one other person, which is just A n − k ways. Thus there are a total of ( k n ) A n − k total ways.
...
Case n : n people are alone.
There is 1 way to do this.
Thus, A n = 2 ( 2 n ) − ( 1 n ) A n − 1 − ( 2 n ) A n − 2 − ⋯ − ( n n ) A 1 .
We can easily compute A 5 by the above formula: A 0 A 1 A 2 A 3 A 4 A 5 = 1 = 1 = 1 = 4 = 4 1 = 7 6 8 . □
Log in to reply
I did the same thing - probably should have seen PIE though.
Hi! This solution is really awesome!! But may i ask is there any typo in your solution? We shouldn't have A 1 in the expression to find A n right? A 3 = 2 ( 2 3 ) − ( 1 3 ) A 2 − ( 2 3 ) A 1 − ( 3 3 ) A 0 = 1 not 4?
We can complete the following matrix of friendship (up to diagonal line) with 1 for 'friends' and 0 for 'no friends'. We can do this in 2^10 = 1024 ways. Now, we have to eliminate the cases when a person have 'no friends' 4* 2^6 = 256. So, we obtain * 768 * ways.
ff 1 2 3 4 5
1 - * * * *
2 * - * * *
3 * * - * *
4 * * * - *
5 * * * * -
Problem Loading...
Note Loading...
Set Loading...
Number of connection between those 5 people is 2 5 × 4 = 1 0 . Each connection has two possibilities (friend or not friend). So, the number of ways for 5 people to be friends with each other is 2 1 0 = 1 0 2 4
Now, we calculate the number of way if one person is not friends with no one. There are 2 6 ways for the other 4 people to be friends with each other. Then the number of ways for 1 person not to be friends with others = 5 × 2 6 = 3 2 0
Using the same calculation we get:
Number of ways for 2 person not to be friends with others = 2 5 × 4 × 2 3 = 8 0
Number of ways for 3 person not to be friends with others = 3 × 2 5 × 4 × 3 × 2 1 = 2 0
Number of ways for 4 person not to be friends with others = 4 × 3 × 2 × 1 5 × 4 × 3 × 2 × 2 0 = 5
Number of ways for 5 person not to be friends with others = 1 × 2 0 = 1
So, the number of ways for 5 people to be friends with each other, such that each person is friends with at least 1 other person in the group = 1 0 2 4 − 3 2 0 + 8 0 − 2 0 + 5 − 1 = 7 6 8