/content/articles/elevator-logic.mdx
[ READ ONLY ]
The Hidden Logic of Elevators
> Why do you have to wait so long? The math behind the buttons.
Have you ever wondered why elevators seem to take forever when you're in a rush? It's not just bad luck; it's a complex mathematical problem called the Elevator Algorithm.
The Basics
Elevators don't just go up and down randomly. They follow a specific set of rules to maximize efficiency.
- Keep going in the current direction until there are no more requests in that direction.
- Switch direction only when the current direction is clear.
This is also known as the SCAN algorithm, and it's used in hard disk drives too!
Why it feels slow
The problem is that the algorithm optimizes for the average wait time of everyone, not your specific wait time. So while you wait, the elevator might be picking up three other people on the way down.