The hotel with infinitely many rooms
A hotel has infinitely many rooms, numbered 1, 2, 3, and so on without end, and every room is occupied. Guests can be asked to move, all at the same time, to a new room number that you announce.
- A new guest arrives. How do you fit her in?
- An infinite coach arrives carrying passengers numbered 1, 2, 3, ... How do you fit them all in?
- Infinitely many such coaches arrive at once, each carrying infinitely many passengers. How do you fit everyone in?
Show a hint
For one guest, shift everyone up one. For a coach-load, make the current guests take only the even rooms. For infinitely many coaches, find a way to give every (coach, seat) pair its own room number, for example with prime numbers or with a diagonal zigzag.
Your answer
Solving needs a free account
Answers, streaks and solutions unlock when you are signed in. Reading the question and the hint stays free.
Discussion
Sign in to join the discussion · reading is open to everyone
💡 Discussion rules
- No full solutions here. Hints and approaches only.
- Complexity, edge cases and intuition are the point.
- Interview experiences are welcome. Respect your NDAs.
Loading discussion…
Learn the concepts
The theory behind this question.
Related questions
Is 0.999... really equal to 1?The airplane on a treadmillAli and the eight loavesTwice as old as you were when I was your ageThe average speed that cannot be reached
All questions →