Fractal interview question

Elevator logic