# PUZZLER - 100 Passengers boarding a Plane

**URL:** <https://community.cartalk.com/t/puzzler-100-passengers-boarding-a-plane/91742>\
**Category:** The Show\
**Created:** [November 18, 2015, 8:43pm UTC](https://community.cartalk.com/t/puzzler-100-passengers-boarding-a-plane/91742 "2015-11-18T20:43:51Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![DwibDwib](https://avatars.discourse-cdn.com/v4/letter/d/0ea827/32.png) [@DwibDwib](https://community.cartalk.com/u/DwibDwib)\
**Post date:** [November 18, 2015, 8:43pm UTC](https://community.cartalk.com/t/puzzler-100-passengers-boarding-a-plane/91742/1 "2015-11-18T20:43:51Z")

</div>

This has to do with last week’s Puzzler on The Best of Car Talk. Here is the puzzler…

A plane has 100 seats and 100 passengers are boarding with assigned seats.  
The first passenger to board looses their ticket and, sits in a random seat.  
Subsequent passengers board and, if their seat is already taken, they  
find an available seat at random.

THE CHALLENGE  
What are the odds that YOU (being the last person to board the plane) will sit in your assigned seat?

The answer was, I think, 50% and the logic seemed pretty fuzzy to me. SO… I wrote up a MatLab program to iteratively test it out. With a large number of runs (100000) the answer was that 66% of the time (2 out of 3) you seat in your assigned seat.

Did I just mis-hear the Car Talk answer or were Tom and Ray WRONG!!!

Here is my MatLab program:

function [TheOdds]=CarTalkPuzzle01(Ntimes)  
% THE PUZZLE  
% A plane has 100 seats and 100 passengers are boarding with assigned seats.  
% The first passenger to board looses their ticket and, sits in a random seat.  
% Subsequent passengers board and, if their seat is already taken, they  
% find an available seat at random.  
%  
% THE CHALLENGE  
% What are the odds that YOU (being the last person to board the plane)  
% will sit in your assigned seat?  
%  
TheResult = zeros(Ntimes,1); % pre-allocate the array  
% Run the PUZZLE a bunch of times for better statisical results  
for n=1:Ntimes  
% All the passengers have their tickets and assigned seats  
SeatAssignment = 1:100;  
% Keep track of which seats are taken during the process of boarding the plane  
SeatFilled = zeros(100,1);

```
% Passenger #1 looses their ticket and sits in a random seat
RandomSeat = Rand_1to100();
SeatFilled(RandomSeat) = 1;

% The next 98 passengers seat down
for p=2:98
    TheSeatNumber = SeatAssignment(p);
    % Is someone sitting in passenger seat?
    if SeatFilled(TheSeatNumber)==1
        % Find a randomly OPEN seat and take it
        while SeatFilled(TheSeatNumber)==1
            TheSeatNumber = Rand_1to100();
        end
    end
    SeatFilled(TheSeatNumber) = 1;
end
% The result is the whether YOUR seat (being passenger #100) is taken
if SeatFilled(100)==0
    TheResult(n) = 1; % My Seat Is Empty!!! Yeah!!!
else
    TheResult(n) = 0; % My Seat Is Already Taken!!! Yuck!!!
end

```

end  
TheOdds = sum(TheResult)/Ntimes;

function [TheNumber]=Rand\_1to100()  
% Create a random number between 1 and 100  
TheNumber = floor(100\*(rand(1,1))+1);  
% Limit the number to between 1 and 100  
TheNumber = max(1,min(100,TheNumber));

---

<div class="post-metadata">

**Author:** ![insightful](https://sea1.discourse-cdn.com/cartalk/user_avatar/community.cartalk.com/insightful/32/2732_2.png) [@insightful](https://community.cartalk.com/u/insightful)\
**Post date:** [November 19, 2015, 3:03am UTC](https://community.cartalk.com/t/puzzler-100-passengers-boarding-a-plane/91742/2 "2015-11-19T03:03:08Z")

</div>

When I solved it rigorously for 2, 3, and 4 total passengers, I got 50% each time. Are you sure you’re keeping track of the seats taken and the fact that the subsequent passengers have a reduced number of seats available?

---

<div class="post-metadata">

**Author:** ![DwibDwib](https://avatars.discourse-cdn.com/v4/letter/d/0ea827/32.png) [@DwibDwib](https://community.cartalk.com/u/DwibDwib)\
**Post date:** [November 19, 2015, 3:34am UTC](https://community.cartalk.com/t/puzzler-100-passengers-boarding-a-plane/91742/3 "2015-11-19T03:34:22Z")

</div>

My algorithm for subsequent passengers (if their seat is taken) is for that passenger  
o to randomly pick a seat  
o is it taken?  
\> Yes = try again  
\> No = take that seat and flag the seat as taken  
I think this properly simulates a passenger looking for an open seat.

---

<div class="post-metadata">

**Author:** ![insightful](https://sea1.discourse-cdn.com/cartalk/user_avatar/community.cartalk.com/insightful/32/2732_2.png) [@insightful](https://community.cartalk.com/u/insightful)\
**Post date:** [November 19, 2015, 3:40am UTC](https://community.cartalk.com/t/puzzler-100-passengers-boarding-a-plane/91742/4 "2015-11-19T03:40:41Z")

</div>

Can you rewrite your program for 4 total passengers and see how it works?

---

<div class="post-metadata">

**Author:** ![insightful](https://sea1.discourse-cdn.com/cartalk/user_avatar/community.cartalk.com/insightful/32/2732_2.png) [@insightful](https://community.cartalk.com/u/insightful)\
**Post date:** [November 19, 2015, 5:39am UTC](https://community.cartalk.com/t/puzzler-100-passengers-boarding-a-plane/91742/5 "2015-11-19T05:39:23Z")

</div>

I Googled : _airplane passenger getting seat probability puzzle_, and got several hits. All agree the answer is 50%. One explanation:

> The key observation is this: when the last person boards, the only possibilities for the empty seat are the correct seat, or the seat assigned to the first person. Why? well, if the seat assigned to the 16th person to board is free when the last person boards, then it was also free when the 16th person boarded, so she would have taken it then, a contradiction; and the same contradiction works for everyone else after the first person to board.

I can’t help you with your program, though.

---

<div class="post-metadata">

**Author:** ![DwibDwib](https://avatars.discourse-cdn.com/v4/letter/d/0ea827/32.png) [@DwibDwib](https://community.cartalk.com/u/DwibDwib)\
**Post date:** [November 20, 2015, 1:03am UTC](https://community.cartalk.com/t/puzzler-100-passengers-boarding-a-plane/91742/6 "2015-11-20T01:03:30Z")

</div>

Okay, I rewrote the program with a better random number generator AND randomized the passenger tickers and now it works… 50% chance. Yeah!

function [TheOdds]=CarTalkPuzzle02(Ntimes)  
% THE PUZZLE  
% A plane has 100 seats and 100 passengers are boarding with assigned seats.  
% The first passenger to board looses their ticket and, sits in a random seat.  
% Subsequent passengers board and, if their seat is already taken, they  
% find an available seat at random.  
%  
% THE CHALLENGE  
% What are the odds that YOU (being the last person to board the plane)  
% will sit in your assigned seat?  
%  
rng(‘shuffle’); % randomize random number gernerator  
TheResult = zeros(Ntimes,1); % pre-allocate the array  
% Run the PUZZLE a bunch of times for better statisical results  
for n=1:Ntimes  
% Assigned seats at random  
SeatAssignment = zeros(100,1);  
for p=1:100  
TheSeatNumber = randi(100);  
while ~isempty(SeatAssignment(SeatAssignment==TheSeatNumber))  
TheSeatNumber = randi(100);  
end  
SeatAssignment§ = TheSeatNumber;  
end  
% Keep track of which seats are taken during the process of boarding the plane.  
% 0 = seat is empty and 1 = seat is filled  
SeatFilled = zeros(100,1);  
% Passenger #1 looses their ticket and sits in a random seat  
RandomSeat = randi(100);  
SeatFilled(RandomSeat) = 1;

```
% The next 99 passengers seat down
for p=2:100
    TheSeatNumber = SeatAssignment(p);
    % Is someone sitting in passenger seat?
    if SeatFilled(TheSeatNumber)==1
        % Find a randomly OPEN seat and take it
        while SeatFilled(TheSeatNumber)==1
            % Select a random seat
            TheSeatNumber = randi(100);
        end
    end
    SeatFilled(TheSeatNumber) = 1;
end
% Did I sit in my originally assigned seat?
if TheSeatNumber==SeatAssignment(100)
    TheResult(n) = 1; % YES
else
    TheResult(n) = 0; % NO
end

```

end  
TheOdds = sum(TheResult)/Ntimes;

---

<div class="post-metadata">

**Author:** ![insightful](https://sea1.discourse-cdn.com/cartalk/user_avatar/community.cartalk.com/insightful/32/2732_2.png) [@insightful](https://community.cartalk.com/u/insightful)\
**Post date:** [November 20, 2015, 1:58am UTC](https://community.cartalk.com/t/puzzler-100-passengers-boarding-a-plane/91742/7 "2015-11-20T01:58:02Z")

</div>

Cool, I’ve been wondering what a MatLab program looks like. Not horribly different from FORTRAN or Basic.

---

<div class="post-metadata">

**Author:** ![Yosemite](https://sea1.discourse-cdn.com/cartalk/user_avatar/community.cartalk.com/yosemite/32/643_2.png) [@Yosemite](https://community.cartalk.com/u/Yosemite)\
**Post date:** [November 20, 2015, 7:43am UTC](https://community.cartalk.com/t/puzzler-100-passengers-boarding-a-plane/91742/8 "2015-11-20T07:43:27Z")

</div>

I think you are all wrong.  
I think that 99% will sit in their designated seat.

The airport security would have the passenger in a padded room, questioning how they could lose their ticket after going through the security check.

So the remainder of the passenger would still be able to get their assigned seat.

Yosemite

---

<div class="post-metadata">

**Author:** ![insightful](https://sea1.discourse-cdn.com/cartalk/user_avatar/community.cartalk.com/insightful/32/2732_2.png) [@insightful](https://community.cartalk.com/u/insightful)\
**Post date:** [November 20, 2015, 7:46am UTC](https://community.cartalk.com/t/puzzler-100-passengers-boarding-a-plane/91742/9 "2015-11-20T07:46:46Z")

</div>

I have to admit…I never thought of that…

;-]

---

<div class="post-metadata">

**Author:** ![Yosemite](https://sea1.discourse-cdn.com/cartalk/user_avatar/community.cartalk.com/yosemite/32/643_2.png) [@Yosemite](https://community.cartalk.com/u/Yosemite)\
**Post date:** [November 20, 2015, 8:00am UTC](https://community.cartalk.com/t/puzzler-100-passengers-boarding-a-plane/91742/10 "2015-11-20T08:00:01Z")

</div>

Yea, they would browbeat that poor old lady in the wheelchair because she lost her ticket, but let pass the guy that looks like a terrorist, just to be politically correct.

Yosemite

---

<div class="post-metadata">

**Author:** ![Barkydog](https://sea1.discourse-cdn.com/cartalk/user_avatar/community.cartalk.com/barkydog/32/2470_2.png) [@Barkydog](https://community.cartalk.com/u/Barkydog)\
**Post date:** [November 20, 2015, 8:08am UTC](https://community.cartalk.com/t/puzzler-100-passengers-boarding-a-plane/91742/11 "2015-11-20T08:08:56Z")

</div>

Crap to all, I have 100% I wilI get my seat. Dude I asked for a window seat, this is my assigned seat and you have to move. Any issues from the (pick your word) sitting in my seat security will toss the person.
