PUZZLER - 100 Passengers boarding a Plane

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));

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?

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.

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

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.

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;

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

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

I have to admit…I never thought of that…

;-]

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

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.