**THE PROBLEM**

At Coders Co. we make the world a better place by helping airlines to kick out their passengers in a fair way.

We all heard that using bad algorithms generates a very wrong kind of buzz on social media. Fortunately, it doesn’t have to be the case. In the following lines, we provide a solution and allow you to kick out your passengers truly randomly giving all the people the same chance to be kicked out. There is more: the algorithm can take into account exceptional cases — a wealthy client that just bought the ticket, a 150-kilo athlete that might not be too easy to drag — you only need to know where people that you make exceptions for sit.

We start with Figure 1 that shows a scheme of a typical plane with seats and rows. We assume you know the allocation of people. We first solve a couple of fairly simple cases to build up intuition and then present a more general solution. For now, we assume there are no exceptions and we will cover other cases later.

**ONLY INDIVIDUALS**

Assume, that we checked in people and we need to kick out of them. The simplest case is if all our clients travel on their own. In that case, we can randomly pick of them and that will be fair. For example, we can write down all the names of people and put them into a hat to draw similar to Figure 2.

**INDIVIDUALS AND COUPLES**

Now suppose we also have some couples that travel together. For simplicity, assume that the total amount of checked-in passengers among them we have 3 individual passengers: A, B, and C; and a couple D and E. Suppose, we need to kick out persons. We assume that we only want to kick out D and E together since they are travelling together and we want to treat our customers well.

We can pick 2 persons from the individuals and there are 3 possible combinations: AB, AC and BC. Alternatively, we can kick the only natural couple we have DE. Now it is the time to write each of the possible pairs on a piece of paper and put it in the hat. The only thing is, to make sure that every person has the same chance to be picked, we need to put the pair DE to the hat twice. The reason is any other person except for D and E is a member of two possible combinations and will be in the hat on two pieces of paper. Therefore, the hat pieces of paper composition should be AB 1, AC 1, BC 1, DE 2.

Now, suppose there are passengers that we checked-in, couples and we need to kick 3 people. We can use a similar logic to solve this case. If we only pick from individuals, each of them can be a member of tripletons. On top of that, he can join one of the couples to form a tripleton. As far as members of couples are concerned, they can make a tripleton with one of the individuals. Now, to make sure everybody has the same chance to be selected we need to balance the number of times tripletons are build from individuals with the number of times they are built from individuals and couples.

Suppose that each triplet constructed from individuals only is there once and the tripletons constructed from individuals and couples are there times. Then, each individual is there

Whereas, each member of a couple is there

Now, to ensure that everybody has the same chance of being selected those two numbers should be the same. So we get

putting things that contain W to the left-hand-side and the rest to the right-hand-side we obtain

Solving for yields

##### CONCLUDING REMARKS

In general, if we have checked-in passengers, couples and people to kick we can use a similar logic. There are only individuals and each individual can be a part of different pairs (he can make a pair with any other individual). Having said that, we also can consider cases 4 people travelling together (families with kids). Of course, if we want to exclude somebody from being drawn, we just not include this person to the list of checked-in passengers.

If you or your company struggles with a similar problem contact me or us at Coders Co. We might not help you kicking out your passengers, but we can develop software that picks them randomly in a fair way.