 What's up guys, we're gonna do another spodge problem today. We are going to do this thing called What was the problem actually? What was the problem? I don't actually remember what the problem is. Hold up Girls and boys. Yeah, we're gonna do girls and boys I'm pretty tired right now So and I have to whisper because there's too many people in my house right now So yeah today we're gonna go do girls and boys Basically given G girls and B boys and then you want to arrange them in a single row You want to avoid having too many girls and too many boys sitting next to each other So you want to minimize this gender regularity? So basically you want to arrange is a maximum number of students in the same gender that appear Consecrately yeah, the gender regularity is a maximum number of students of the same gender that appeared Consecratively so now you want to calculate the minimum gender regularity among all possible arrangements. Okay So this is actually just using the pigeonhole principle if you know what the prison pigeonhole principle is Basically it's saying that like If you have like n pigeons Excuse me, and there's m boxes, right and sooner or later you're gonna have at least one is gonna be Well, at least one is gonna be in the same box, right if you end pigeons and you're trying to fit m boxes Sooner or later one of them is gonna be in the same box if it's greater But yeah Yeah, I'll just show you guys how the code works because it's actually not that bad Basically, you're just gonna want to take the larger number and divide it by the smaller number plus one and Find the remainder of that and then yeah, that's pretty much it. That's all you have to do There's not much to it So let's actually go to the solution. So let's do this alright So here we have do while and I use a do while because they said end everything if both of them are equal to negative one Right, so I have my two numbers x and y I read them in If they equal to negative one both equal negative one, I'm gonna break and that would just end the program Otherwise, I need to check if they're equal to zero if they're equal both equal to zero then the answer is zero Because like you have zero boxes zero things. So you can't really do anything. You're gonna have zero Now if they're equal to each other well at that point All the girls and boys are gonna be in the same line. So it's the answers to be one You know, I could show you guys what I mean by that Imagine have g girls and b boys and basically I just want to make sure that they don't sit in the same row So like I don't want I want to have imagine we have Three girls and three boys, right? Well, if I do if I put them all on the same spot spot here The number of consecutive G's is three number consecutive B's is three and that's not what I want I don't want that. I want the minimum, right? I want a minimum consecutive. So instead what I'm gonna do is I'm gonna put GB GB GB right so in the end here the consecutive is always gonna be one right because there's not there's only one G that's In the same row as each other. There's only one B. That's consecutive, right? There's these change. They're not in the same same. You don't see two GGs, right? You don't see number these so that's why here the answer would just be One if they're both equal, right? If three is equal to three answer would just be one So that's what I have here. All right So anyway using the pigeon home principle if x is less than y first of all we need to swap the values We want to have the larger value first because I'm gonna do that here. All right So, yeah, we have we're gonna swap the values first All right now using the pigeon whole principle if I take x and I I'm gonna modify y plus one right, so I'm gonna divide it by it and If it's equal to zero right then I'm just gonna print out x divided by y plus one otherwise, I'm going to put the the Answer plus one and the reason why we do answer plus one is because at that point answer plus one or just be like the higher The upper more higher value of what it would be here. So that's what it would be like That's pretty much suggestive this if x not equal to negative one and y not equal to anyone then yeah But yeah, that's pretty much suggestive this problem The reason why we do this plus one is because this is like the ceiling we're using the ceiling I didn't feel like using the ceiling function. So it's better to do it this way But that's all you have to do for this problem Hope you guys enjoyed this video right come subscribe. This was the part of the next value of spodge. So yeah peace