 Hi, I'm Zor. Welcome to Unisor Education. This is another problem-solving lecture about combinatorics. And as usually, I would like to point a very important aspect of these problem-solving lectures. For educational purposes, you really have to go to the Unisor.com website and first check the notes for this lecture, which contain basically the problems themselves. Then there is an answer, so you can basically check your own skills, try to solve the problem yourself, and then look at the answer, it should actually be the same. Now the formula might look a little differently, and that's what I will actually talk about during this lecture a couple of times, but the result should be the same. It doesn't really matter how the formula looks like, it should be identical. So I do encourage you to do this type of preliminary problem-solving first, and then go to this lecture. Now another very important aspect of combinatorics problems is, as I was saying before a couple of times, it's very difficult to check really whether your answer is correct or not, because there is no easy way to check, for instance, if you solve the equation, for instance, you just substitute it and check if you have identity, right? Here you come up with some formula which signifies something, but you don't really know whether it's correct or not. The best way to check these answers which you obtain is through some kind of other way to come up with the same result. So if you can approach the same problem from two different directions and come up with the same result, that's the best check you can get. Now in cases when you have to count certain things, and that's what combinatorics is all about, you have to count something. There are two ways to count. You can count all the objects which belong to certain category and basically come up with an answer, or alternatively you can count all the objects which do not belong, which are excluded from this category. So if the total number of objects is known and you know how much is excluded, then you can get basically what's in that particular set. And that's probably the best way to do these problems. Try to approach it from both ways, inclusive and exclusive ways. And that's what I will try to show you. Problem number one. The reason inside it convects polygon. Let's make it more something like this. One, two, three, four, five, six, six different vertices. Alright, now what we can do is we can build triangles based on the vertices of this polygon. For instance, this one. This is a triangle. Right? Now, this is another triangle. Let me use another color. Okay? And there are some other triangles. Now, I'm interested only in the triangles which do not have the side which coincides with any one of the sides of the polygon. So this triangle is not good because this side coincides with the polygon side. The red triangle is good. So I would like to count only these triangles which do not have common sides with the polygon. Okay, so how can I count them? Well, let's just do it again with two different ways. First, let me try to do the exclusion method. So I would like to exclude from all the triangles those which have common sides. Okay? Now, how can we do it? The number of triangles which I can form using n different vertices of the polygon is obviously number of combinations from n to 3. So that's my initial number of all triangles. Now, let me exclude those which have common sides with the polygon. Well, let's assume that n is greater than 3. So we have more than 3 points actually, more than 3 vertices. Now, if n is greater than 3, obviously I cannot have my 3 sides coincide. 3 sides of the triangle coincide with 3 sides of the polygon. So it can be either two sides of the triangle are coinciding or just one side. Okay? So let's start with two sides coinciding. Now, if two sides of the triangle coincide with the sides of the polygon, that must be this. Let me just give you an example of a triangle which has two sides coinciding. It's this one. Right? So you have one vertex and two sides of the polygon immediately adjacent to this vertex and the one which connects these two sides. So these are the only type of triangles when three points are all neighbors to each other in the polygon, when these triangles are possible to construct. Now, how many of these triangles exist? Well, each triangle such is uniquely determined by the vertex of the polygon. So on every vertex of the polygon, I can have a triangle like that. This, this, this, etc. Right? So the number of these triangles which have two sides coinciding with the sides of the polygon is exactly n and I have to subtract it. Now, let me wipe this out because the next one will be slightly more complicated. Now, I have again a polygon and now I'm interested only in triangles which have only one side coinciding with. So that's something like this. This is the triangle. One side coincides. Now, which one can coincide? Well, obviously there are as many sides as many the polygon has. So it's n and what kind of different triangles we can construct with this side coinciding with the polygon? Well, it's anyone except immediately adjacent because immediately adjacent will have two sides. Right? This is two sides coinciding, triangle which coincides with two sides, but we have already counted them. So we need to exclude not only these two vertices which are forming my side from which which is coinciding with the triangle, but also it's needed to neighbors. So I have to exclude four points for the third vertex of the triangle. So I have to multiply number of sides by n minus 4. That's number of vertices where the third vertex of a triangle can be positioned so the triangle has only one side coinciding with the polygon. So that's basically it. That's the answer. Fine. Good enough. Actually it can be done explicitly, basically, including, inclusively, I should say, explicitly calculate all triangles which are supposed to be included into this category. It's a little bit longer logic and I basically presented it in the notes for this lecture. I don't want really to spend a lot of time on this right now, but there is another way. Now here I have a total count of triangles and excluded those which are not supposed to belong. Now in that other logic which I presented in the notes in this Unisor.com site, I count explicitly all the triangles which are supposed to be included in this category. And I do suggest you to basically go through the notes and see what exactly the other logic is. It's a little bit lengthier. That's why I don't want to present it here. So let's go to the next problem. And what's interesting is obviously that it presents exactly the same result, but in a slightly different formulation, so to speak. So it's the same, basically, formula but positioned slightly differently in any case. Let's go on. On the plane we have n straight lines and each line has k points on it. So we have n lines, k points on each. Now let's just make some reasonable assumption. Lines are not parallel. Notary lines are intersecting at the same point. And these k points given on each line do not coincide with intersections of the line. So intersection is not part of this. So it's all kind of the most general case. Let's put it this way. The most common, right, this case. Now I would like to count how many different triangles can be formed using these points. Alright? Okay. Now, I can form triangles by using points from different lines. I cannot use one line and have three points on it to form a triangle because all these points are on the same line, right? So they don't form triangles. So I have to introduce either two lines for three points or all three lines for three points, right? So let's just count them separately. I want all my three points of the triangle to lie on three different lines, alright? Now, obviously it depends on number one. Which three lines out of n I choose. And there are a number of combinations. Now, as soon as I have chosen my three lines, I have a freedom of building different triangles using the points lying one on one line, another on another line, and the third one on the third line, right? So I have k choices for the first point, k choices for the second, and k choices for the third. Each one was each. So that makes it k times k. So that's number of triangles which I can form using three points and three different lines. Alright, that's good. Now, let's count how many triangles I can build using only two lines, right? So let's say I have this line and this line. Well, first of all, I have to choose two lines, right? So that's number of my combinations of two lines. Now, given a concrete two lines, I can build triangles using either two points on one and one point on another, or two points on this and one point on this. And that would make triangles. So it's either this way or this way. Since I really have to double the count of all triangles when two points on this line and one point on that line, right? So I double it. And now, how many different cases of this exist? Well, I have to choose two points here out of k, which is this, number of combinations of two points out of k. I have to multiply by number of combinations of one point out of k, which is k. And that's the answer. On another hand, let's just approach the whole problem differently. Instead of counting inclusively which triangles really belong to my category, I will choose differently. Let's say I'm connecting any three points out of whatever is given. So how many points do I have? m times k, right? And lines k points on each. And I choose three points any way I want. So this is a number of triplets, but not all of them make up the triangles, right? So let's exclude those which do not. Now, I have to exclude all the cases when three points are not making a triangle. And that's the only one when three points belong to the same line. So they can belong to this line, to this line, or to this line. It doesn't really matter. There are n different choices for the line. And within the line, I can just check, I can choose any three points out of k, which is this. And that would be a triplet which does not make a triangle. So any other combination of lines and points. So when only two or one is a point on each line, that actually makes a real triangle. So this is yet another formula. Well, the question is, it's completely different, right? All right, well, when I came up with these two formulas, I was kind of surprised. And then I decided basically to try to find out whether it's really the same or a different formula. Well, obviously, if it was very different, I wouldn't really tell it to, right? So it's the same. And if you want, you can basically do the calculation. What's cn of three? It's n times n minus one times n minus two divided by three factorial, which is six times k cube plus n n minus one over two times two times k k minus one over two times k. So it's k square. So that's what I have in the trope. And on the bottom, I have something similar. You can just again do whatever these, you know, whatever this formula actually calls for. You simplify and you will get exactly the same result. The same formula which contains as a polynomial, for instance, of n and k. I don't want to go through this. I did it once. And well, obviously you can believe me, but I do suggest you to do it yourself. I think it's very educational to see that completely different formula actually is the same formula, just presented in a slightly different way. All right. So that's what I meant is that solving the problem using these two ways actually assured me that the solution is correct. Because otherwise, well, maybe I forgot this case. Maybe I forgot that case to count, et cetera. That's not obvious. All right. Number three. Okay. You have a number, a natural number n, which is greater than three. And you would like to represent it as a sum of three different numbers, also natural numbers, starting from one and et cetera. And the different combinations, for instance, this combination and this combination are considered to be different. So the order is important, right? So this is also a seven, but these are not the same combinations. So I have to find out how many different combinations. Oh, by the way, identical numbers also allow two plus two plus three. That's fine, too, which is not the same as, let's say, two plus three plus two. Right? So order is important, but other than that, there are no restrictions. So the question is how many different combinations, representations of a natural number n as a sum of three natural numbers are possible. Okay. Now, here is the way how you can do it again, inclusively and exclusively. Let's do it this way. First of all, none of these numbers, a, b and c, can be greater than n minus two, right? Because if it's n minus one, for instance, then even if these two are one and one, we get more than n. So the maximum is a, b and c, they are from one to n minus two. Okay, let's do it one by one. Let's consider n is equal to n minus two. That's one particular, the first number, for instance. How many different combinations of the second and third we have? Well, it can be either one, one, and basically none others. So it's one combination. If a is equal to n minus one, I can have, I am sorry, minus three. I go down. I decrease. So I have to make up three from two numbers. So it's either one, two, or two, one. So it's two different choices, right? For a is equal to n minus four, I have to make up the number four from two numbers. So it's either one, three, or two, two, or three, one. So it's three choices. So as you see, if a is equal to one, the smallest one, I have to make up n minus one out of two numbers, which is one, n minus two, or two, n minus three, etc., or n minus two, one. So it's n minus two choices, right? B from one to n minus two. So to summarize, how many choices do I have? Well, I just have to summarize these numbers. So it's some from one to n minus two. Now, remember what it is? I don't. So I always do it this way. Let's sum up all the numbers from one to k. And I remember that I have to just do it in an opposite order. So this is from one to k. This is from k to one. This is the same thing. Now I sum them together vertically. I have two s of k equals one plus k, k plus one. Two plus k minus one, k plus one, etc. k minus one plus two, k plus one, k plus one, k plus one. I have k plus one. How many times? One, two, three, four, five, k. So sum is equal to k, k plus one, over two. In our case, k is n minus two, right? So the formula is n minus two, n minus two plus one, which is n minus one, over two, and that's the result. That's how many different pairs, sorry, triplets, we can choose to have their sum equal to n. All right, fine. I would like to approach it differently. Now, how differently? In one of the prior lectures, I had a problem of actually presenting an elegant solution to the following problem. If you have n objects and you divide them into three piles of objects, how many different ways to divide them exist? Well, what I suggest it is let's introduce two dividers or separators, whatever, and place it somewhere in between these objects. So we put all the objects in the line, right, and just put two separators somewhere, and they separate. This is the first pile of objects, this is the second, this is the third. Can we use exactly the same approach here? Let's write n once. So the total number of these ones is equal to n. And then just put two lines somewhere. Well, it actually breaks into sum of one plus two plus one gives four, right? So that actually is the way to do it. What's wrong with this methodology and how many different ways to distribute my n among these three piles are? Well, in this case, I have to basically find two different positions out of n plus two, right? n once and two separators, it gives me n plus two objects. And I have to find how many combinations out of these n plus two by two exist. So these are all the different positions of these separators. And that actually breaks my number n into sum of three numbers. What's wrong with this approach? Well, approach is correct except I do not really have to have zeros. The problem stated that the number is supposed to be natural. But this approach allows me to put separators here, which means the first pile is one, the second one is empty, and the third one is three. So it's one plus zero plus three. And that's not a good combination because it has zero. We have to exclude these combinations. Okay, so how can I exclude the combinations which are not really valid? Okay, let's just think about it. Well, in my sequence of three numbers, I can have either one zero or two zeros, right? And I would like to count separately how many combinations have one zero. Well, one zero can be either here or here or here. So I have to subtract three times. And for instance, zero is in one particular place. Now how many combinations of these exist? So it's either one and n minus one, two and n minus two, et cetera, n minus one and one, right? So it's n minus one combination, which I have to subtract. So I first I have to choose which one of them is zero and then all the different pairs of other two which add up to n, I count. All right, now how many combinations are with two zeros? With two zeros, I have basically three combinations, right? Zero, zero, n, zero, n, zero, and n, zero, zero, right? There are no other combinations with two zeros which give n as a sum. So I have to subtract three. Now in this particular case, it's very easy to prove that this and this are exactly the same. The calculations are not as lengthy as in the prior cases. And in the prior cases, it's also valid different representation. In this case, it's just a little bit easier. So this gives me n plus two times n plus one, n plus two minus one, right? Over two minus three times n minus three n plus three minus three. So it's minus three n, right? And this is equal to this because n square plus three n, just one second, plus three n. This is n square, n square plus three, no, minus, yes, plus three n, plus two. That's what it is, right? n plus two times n plus one, that's what it is. I subtract three n and that gives me two times three is six, so it gives me this. Okay, how about this? n square minus one and two, three n, and plus two, right, exactly the same thing. So these are the same formulas, just presented slightly different. All right, again, I have chosen to use two different ways to prove this, and that's very important. And the last problem, which is, maybe it's less combinatorial, but anyway, let's consider people are shaking hands with each other. All the people in the earth, whatever. Now, there are certain people who shook hands odd number of times. Odd number of handshakes. Now, my statement is that number of these people who shook hands odd number of times is actually even. Why? Well, let's consider. Every handshake is supposed to be, if I want to count how many handshakes all people have altogether. I have to count each and had handshake twice for one person and for another person. So the total number of handshake is even. Now, let's divide people into two categories. Those who made odd number of handshakes and those who made even number of handshakes. Well, those who made even number of handshakes, if I will summarize their handshakes, it would be even plus even plus even plus even, right? This is total number. Now, the number of people who are making even number of handshakes even. Now, what does it actually mean? That the total number of handshakes which these people made is also even, right? Because from total number of handshakes, I have to subtract the total number of handshakes made by people who made only even number of handshakes. And that would result in the number of handshakes which made by people who made odd one. Now, so my question is, if this number is odd, number of people who made odd number of handshakes, then their sum would be odd, right? The odd number of odd numbers added together is odd. So it must be even. That's basically it. Alright, anyway, thanks a lot for your attention. Good luck and I do recommend you to go through these problems again on Unizord.com. And well, let's continue with more problems. I have a lot of problems in combinatorics for you. Thank you.