## Problem

There’s an airplane with 100 seats, and there are 100 ticketed passengers each with an assigned seat. They line up to board in some random order. However, the first person to board is the worst person alive, and just sits in a random seat, without even looking at his boarding pass. Each subsequent passenger sits in his or her own assigned seat if it’s empty, but sits in a random open seat if the assigned seat is occupied. What is the probability that you, the hundredth passenger to board, finds your seat unoccupied?

## Solution

```
from random import sample
= 10000
runs = 100
num_seats = 0
cnt_success for _ in range(runs):
= set(range(num_seats))
seats = sample(seats, 1)[0]
first_seat
seats.remove(first_seat)for i in range(1, num_seats-1):
if i in seats:
seats.remove(i)else:
= sample(seats, 1)[0]
seat
seats.remove(seat)if num_seats-1 in seats:
+= 1
cnt_success print(cnt_success/runs)
```

The probability of the hundredth passenger finding his or her seat unoccupied is \(0.5\). This probability is independent of the number of seats/passengers.