A nice one I heard at the office the other week. Not necessarily a programming thing though, but here goes:
You are the last one of a queue of 100 people, waiting to get aboard of an airplane with exactly 100 seats. All have a reserved seat. There is, however, a confused person (not you of course) who will pick a free seat at random. For all others it holds that each will take his reserved set, unless occupied, in which case he himself will also pick a free seat at random. The question is of course: what is the chance that you'll end up in your reserved seat?
I'm not sure I can even figure this out for a queue of 2 people.
We know that 1 is the confused person and that they will pick a seat at random. So 1 either picks seat 1 (their assigned seat) or seat 2 (my seat), each with probability 1/2. Then I pick the other seat, which is my seat with probability 1/2.
If I'm right, then with 3 people in the queue the chance that I will get my assigned seat is still 1/2, there's just a more tedious enumeration of possibilities. So obviously the answer to Piet's original question is 1/2.
posted 1 year ago
Paul is spot on. But how to prove it? Well, suppose that person A is trying to get to his seat. A is not the confused person, but he finds his seat taken. So now A himself picks a seat at random, as if he was the confused person.
Can you find a two line proof, using mathematical (full) induction? Or can you think of a way to let the computer calculate it?
Incorrect. If it is Junilu sitting in your seat, you'd be flying through the air much sooner than the plane.
But given the many non-serious reactions, I'll put my next puzzle (if at all) in the Meaningless Drivel.